markmarkoh / datamaps

Customizable SVG map visualizations for the web in a single Javascript file using D3.js
http://datamaps.github.io
MIT License
3.78k stars 1.01k forks source link

Datamaps bubbles not in accurate position on map #455

Open anweshadutta95 opened 6 years ago

anweshadutta95 commented 6 years ago

Hey, I'm using datamaps for showing locators on world map wherever a preconfigured agent is running. I'm fetching the exact latitude and longitude values from MySQL DB for the agent locations, and passing them as a json to my js function where the map is getting implemented. It's all working fine except that, all the locators are being shifted a little towards the right-bottom from it's actual position. The locator image I'm using is an 18x18 image of a map pointer. Due to the shift, there's an inaccuracy of agent locations on the entire map. Is there any predefined offset datamaps plugin uses? Please help me with the same. Stuck with this issue for a while now. Thanks in advance.

mpothier commented 6 years ago

I'm having a similar issue - I have a map of the US with a single bubble in each state, defined by precise latitude/longitude coordinates. If I place just a single bubble, it is accurately placed within the map; however, if I place all 50 bubbles, I see the same shifted behavior described by anweshadutta95.

anweshadutta95 commented 6 years ago

I had solved the issue. I had to subtract 20 from each of the longitude values. Had to manually figure out after some hit and trial.

Thanks.

On Thu, Aug 16, 2018, 10:15 AM mpothier notifications@github.com wrote:

I'm having a similar issue - I have a map of the US with a single bubble in each state, defined by precise latitude/longitude coordinates. If I place just a single bubble, it is accurately placed within the map; however, if I place all 50 bubbles, I see the same shifted behavior described by anweshadutta95.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markmarkoh/datamaps/issues/455#issuecomment-413424574, or mute the thread https://github.com/notifications/unsubscribe-auth/AnJjiESpEIVh1yyfqcFOBK3y2JYKCqkhks5uRPjTgaJpZM4VNTRd .

mpothier commented 6 years ago

Unfortunately this didn't work for me - the bubbles are not all shifted the same amount (some are more off than others). I'm wondering if there is a projection issue in how the coordinates are being interpreted?

For reference, i'm using standard WGS84 lat/long in the following format: latitude: 31.891483, longitude: -104.860727

I still can't understand why that coordinate is accurate by itself, but shifted away when placed among other bubbles.

EDIT: Turned out to be a pretty dumb mistake, my coordinates were parsed as integers instead of floats. Everything appears to be in order after all.