neveldo / jQuery-Mapael

jQuery plugin based on raphael.js that allows you to display dynamic vector maps
https://www.vincentbroute.fr/mapael/
MIT License
1.01k stars 195 forks source link

getCoords function (Mercator projection) #255

Closed SafaaFX closed 8 years ago

SafaaFX commented 8 years ago

Hello, first of all thank you so much for this amazing plugin, I'm using it on my project. in the first version of the project I used just the map world_countries and everything was good. Now I'm preparing a new version where I want to add the subcontinents maps.

I managed to add the maps from svg files, but the problem is the getcoords function. I'm using a mercator projection so,I tried this algorithm here: https://github.com/Indigo744/jQuery-Mapael/blob/e1657c047fbab109591ec80aa880d61ccfcbf411/js/maps/world_countries_mercator.js

for all the other maps I just changed the leftLongitude, rightLongitude, topLatitude, bottomLatitude. but I don't get the plots in their right places!!

I don't know if what I did is right??? any advices please..

Thank you so much,

Safaa.

neveldo commented 8 years ago

Hello @SafaaFX ,

You did it right, it should work with the proper values for leftLongitude, rightLongitude, topLatitude, bottomLatitude.

Are you sure your map is a mercator projection ? (Did you try the algorithm from the miller' one : https://github.com/neveldo/jQuery-Mapael/blob/master/js/maps/world_countries_miller.js just in case ?)

Could you provide a JSFiddle with your map in order to check what could be wrong ?

SafaaFX commented 8 years ago

Hello @neveldo

I just used the miller algo it worked for just some places :/

I had never made a jsfiddle, See if this can help : https://jsfiddle.net/1ts7h4e7/3/

here how the map looks like:

etranger

NY Ottawa and Tokyo are in their right places, berlin Rio Gallegos are not !


In the miller algorithm there's something I didn't get, the leftLongitude=-175.0 and the rightLongitude=190.0 while the longitude is between -180 and +180 right?

form what I understand the left point in the world's map is Attu station (Alaska) long=172.469774 and the right point is in Fidji (Oceania) long=179.970542

I feel like I'm mixing things :S

SafaaFX commented 8 years ago

might the problem be related to the height and width that are variables ?? or is there any requirements for the map container (position:relative/..)?

neveldo commented 8 years ago

Hello,

What is the source of your map ? I have checked it, and it seems not to be a Mercator projector, nor a miller or equirectangular one.

SafaaFX commented 8 years ago

Hello @neveldo Yes you're right. It was our designer who made it I unfortunately don't know from which reference he get it. But for now we found another solution, its to provide directly the x and y coordinates using js and the cursor position...

SafaaFX commented 8 years ago

By the way thank you so much for this amazing plugin. I will let you know once I'm finished to check out the project :D

neveldo commented 8 years ago

You are welcome, I'm glad you appreciate Mapael ! I look forward to discover your project :)

ravivermas commented 6 years ago

Hi Neveldo,

I am new to Mapael and I have used this plugin to convert my own svg map to mapael. But I am facing challenge with getCoords function and I am not able to plot markers with the longitude and latitude which I have for cities on map.

Can you please help me on this @neveldo

neveldo commented 6 years ago

Hello @ravivermas ,

I would be glad to help you, but could you please open a new issue instead of answering on a closed one ? (you can take the opportunity to add some info as your map at its current state (or the SVG), and the projection used).