bjornd / jvectormap

jvectormap.com
GNU Affero General Public License v3.0
1.38k stars 431 forks source link

#208 support for Lines between markers added to JVectorMap #431

Open fdominik opened 6 years ago

fdominik commented 6 years ago

I have added support for creating lines between markers (or rather a points defined by Lat and Long). There is not much functionality (like creating Arcs), but styling of Lines and Line Labels works. Lines can be defined as:

var lines = [
                {points: [[40.66, -73.56], [41.52, -87.37], [35.22, -80.84]], text:"first road"},
                {points: [[31.52, -87.37], [21.18, -157.49]], ,text: "second path"}

            ]

The best to test the functionality is to see lines.html page.

selinafocus commented 6 years ago

hi fdominik, thank u for the pull supporting lines,but i have a problem about overlaying the lines on the shapefile below. the shapefile(just called the base map) and the lines over are in the same coordinate system, but how can i transform these at same time and so these can be displayed correctly? thank u very much!

fdominik commented 6 years ago

I am not really sure if I understand correctly. If you need to redraw the lines (e.g. for some movement of the objects etc...), you can call repositionLines(), which is available If you need some other transformation, the best would be some code example of what you are trying to achieve.

BTW.: I have an update to thus pull request, where I have added toggle switch next to zoom buttons to allow switching on/off the lines on the map. However I am still not satisfied with results (CSS is not my strongest skill) so I will push this later when I will resolve it.

selinafocus commented 6 years ago

thank u for you answer! i didn't make my point. sorry~ i have two kinds of data ,one is polygon shapefile, the other is line shapefile. this two files have the same coordinates(wgs1984),so the line is well displayed over the polygon,for example, the line is in the middle of the polygon. but now i use the processor program transform the polygon and the line shapefiles into jvectormap format independently,so in the jvectormap object these two dismatched. how can i get the Lat and Long of the points of the line that match the polygon well?

gezichenshan commented 6 years ago

@fdominik Thanks for your awesome work. The only problem is that it seems we can only set color for one line?

fdominik commented 6 years ago

@gezichenshan oh indeed, I didn't have this in mind when doing it. I am thinking, is it already working anywhere in jvectormap? I think markers can also have only one color, am I right? I am thinking how this can be realized, maybe adding a new property next to points, text, something like {points: [[31.52, -87.37], [21.18, -157.49]], color: #ffffff, text: "second path"} what do you think? Also I have in my local repo stil a change to it to add UI controls to toggle on/off the lines. However I am not a graphic specialist and still it somehow doesn't look that perfectly like the other controls of jvectormap. So any help would be welcome :)

fdominik commented 6 years ago

@selinafocus I am not sure about the transformation. I haven't used the processor transformation, maybe some unit tests would be nice to see where it doesn't work. the true is there is probably no transformation for lines in the processor, because I have never used the processor yet, so I am not sure how it works. Are you a developer who can take a deep look into it or rather a user of jvector map?

gezichenshan commented 6 years ago

@fdominik Thank you for your reply. Setting a new property "color" is a good choice. Anyway, maybe there is no need to set different color for different line. I am not good at graphic, either. May somebody can help :)