Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing marker pans map because of KML #262

Open
davor77 opened this issue Jun 16, 2017 · 2 comments
Open

Replacing marker pans map because of KML #262

davor77 opened this issue Jun 16, 2017 · 2 comments
Labels

Comments

@davor77
Copy link

davor77 commented Jun 16, 2017

Hi,
I have a group of markers

var markers = new L.FeatureGroup(); 

and i add few markers into that group

while something{
	var LeafIcon = L.Icon.extend({
		options: {
			iconAnchor:   [14, 33],
			popupAnchor:  [0, -33]
		}
	});
       var pin = new LeafIcon({iconUrl: '../Images/Pinovi/test.png'});
      var singleMarker = L.marker(
			[lati, longi], 
			{icon: pin, myCustomId: i, myLink: link})
			.bindPopup(L.popup({maxWidth : 'auto', autoClose:false, closeButton:false})
			.setContent(alias))
			.addTo(map)
			.openPopup()
			.on("click", function(e) {
				//code
			})
			.on("mouseover", function(e) {
                               //code	
			});
         markers.addLayer(singleMarker);
}

then i get bounds of them and fit map acording to it

var bounds = markers.getBounds();
map.fitBounds(bounds);

every time i try to replace existing marker with new one map pans (if i manualy leave them initial bounds) because of

	var KmlLayer = new L.KML(kmlfile, {async: true});
	map.addLayer(KmlLayer);

Please let me know if there is a fix for this or i am doing something wrong.

Thank you

@davor77 davor77 changed the title Replacing marker pans map becouse of KML Replacing marker pans map because of KML Jun 16, 2017
@brunob
Copy link
Collaborator

brunob commented Jun 16, 2017

Added code blocks for better readability, can you provide a fiddle showing your bug please cause there's no mention of fitbounds in kml script ?

@davor77
Copy link
Author

davor77 commented Jun 16, 2017

i created fiddle

all looks fine

problem does not apear on my fiddle but its down to this

link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants