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

Importing data from json #301

Closed lucasmazala closed 7 years ago

lucasmazala commented 7 years ago

Hi, I have a json to pass informations. I would like to know if is it possible instead of using latitude and longitude in json like in the example you gave(Importing data from JSON), can I use a path? So my json would have a field called path and would pass a number to match with the path in svg. If it work this have to appear the information in all area of path (like the whole area of a city) and not a little marker like in the example on your page (Importing data from JSON).

is it possible to do that?

neveldo commented 7 years ago

Hi @lucasmazala ,

Indeed, you can set a specific SVG path to draw the cities on the map. Here is an example where I set an SVG path to draw stars in order to plot the cities : https://rawgit.com/neveldo/jQuery-Mapael/2.1.0/examples/basic/legend_SVG_paths.html . Of course, you can set more complex paths, and you can set a custom path for each city.

I hope it will help you !

lucasmazala commented 7 years ago

Hello, @neveldo! I understood, but instead of appear in a marker, giving latitude and longitude like you did, I would like to appear in the whole city, like the exemple more simple in your website, but I don't want to write the information directly in the tooltip, I would like to pass through a Json.

Example: https://rawgit.com/neveldo/jQuery-Mapael/2.1.0/examples/basic/legend_areas.html

areas: { "department-59": { value: "2617939", href: "#", tooltip: {content: "<span style=\"font-weight:bold;\">Nord (59)
Population : 2617939"} },

Here you wrote directly in the tooltip the information. I would like to pass my Json and appear in the same way that appear in this map!

neveldo commented 7 years ago

Hello,

I'm sorry but I don't understand clearly what you want to achieve. Could you explain more, or maybe, do you have any work in progress that you could show (maybe on through JSFiddle) ?

In fact, the tooltip aims to display textual informations about an area or a city of the map on mouse over. It doesn't aim to display some paths that are part of the map (however, you can still display another complete SVG within the tooltip for instance).

Maybe it can help you : the tooltip.content option accepts a string, but it can also accept a function in which you could retrieve the needed data to display from your JSON object.

Indigo744 commented 7 years ago

@lucasmazala do you need more information or can we close this issue?