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

Create A link between two towns dynamically #359

Open rboughani opened 6 years ago

rboughani commented 6 years ago

Hi everyone,

Is it possible with jQuery Maphael to create dynamically a link between two countries by selecting two countries on the map ? i want to create a link between Algeria and Germany (between them capitals). https://plnkr.co/edit/6HTmbletUftfZxrETSQi?p=preview

Thank you

neveldo commented 6 years ago

Hi @darkmanAmazigh ,

As mentioned in the documentation, this is not possible to do it directlry through mapael options for now :

Option links -> between : "(Array) Array of two elements where the first one is the source of the link and the second one is the destination. Each can be a plotted point ID, an object that stores a latitude and a longitude ({latitude : …, longitude : …}), or an object that stores a x and y coordinates ({x : …, y: …}) "

But I think it could be an interessting (and not quite difficult) feature to add, feel free to contribute if you can !

With the actual release, you still can achieve this because you can draw links by x and y and you can easilly retrieve the x,y of the center of a path, this this example on JSFiddle : http://jsfiddle.net/neveldo/v13meh0g/ . You can store the center (x,y) of the origin country on click and draw the link when the user click on the destination country by triggering an 'update' event on the map with the proper options.

I hope it will help you !