I am building a map using the usaLow.js map. On map init, I call a json method that returns this data:
[{latitude: "40.4258686",longitude: "-86.9080655"}]
With this data I add to the map's data provider (mapData) with this:
mapData.images = [];
for(var i = 0; i < resp.length; ++i){
mapData.images.push({
type: "circle",
color:"#FF0000",
latitude: parseFloat(resp[i].latitude),
longitude: parseFloat(resp[i].longitude)
});
}
map.validateData();
This location should be in Indiana, but this is where I see the marker:
Do lat/long coordinates need to be converted when not using world maps? If so, how can that be done?
edit: Fixed JSON string typo
It seems like you are using a non-calibrated US map. (usaLow.js) This map is distorted for visual purposes and thus not compatible with real latitude/longitude coordinates.
To work around that, you will need to use one of the maps that are calibrated. The options are these:
It is Mercator-calibrated for mainland US. The markers should plot OK, except for Alaska and Hawaii, that area displaced.
This map is fully compatible with coordinates, including Alaska and Hawaii. However, it might not look as appealing:
Both of those maps are bundled with JavaScript Maps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With