1

I'm starting use the Leaflet. I put a marker to test but neither the marker nor the center are in the right local I set. example: I put the marker inside a stadium and it appear outside stadium.

There are something I can do to correct this?

var mapquestUrl = 'this is not a link', mapquestAttribution = "Data CC-By-SA by http://openstreetmap.org/' target='_blank'>OpenStreetMap, Tiles Courtesy of http://open.mapquest.com' target='_blank'>MapQuest", mapquest = new L.TileLayer(mapquestUrl, {maxZoom: 18, attribution: mapquestAttribution, subdomains: ['1','2','3','4']});

map = new L.Map('map', { center: new L.LatLng(-8.842, 13.269), zoom: 15, layers: [nexrad], zoomControl: true });

L.marker([-8.815, 13.227], {icon: greenIcon}).addTo(map) .bindPopup('ooooo') .openPopup();
  • 1
    It will be good if you can share some code. Also take into account how many decimals are you using for the precision of your data – Francisco Puga Feb 7 '14 at 14:52
  • My decimals are just 3: L.marker([-8.814, 13.226]).addTo(map) .bindPopup('ooooo') .openPopup(); – user1573901 Feb 7 '14 at 15:04
1

The problem was with the precision of your point (latitude and longitude).

The exact center of the stadium is "-8.8143, 13.226"

Look at my jsfiddle, I just remove some code to make it clear and focus on the solution: http://jsfiddle.net/sLwYG/1/

Hope it help you =)

| improve this answer | |
  • Thank you very much Thiago. Is just convert the georeference to new L.LatLng. – user1573901 Feb 7 '14 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.