I know that google maps has markers to highlight certain points in the map. I am for some reason not comfortable putting this type of map on my site and love the jvector map effects. But I am not able to figure out how to define markers in the jVectorMap, does anybody have a clue as to how to define the markers in jVectorMap and highlight those points. I would also love to know how would you get to the certain point in jVector Map using latitude and longitude.
Thanks.
Now you can do that, new version of jVectorMap (0.2) introduces such feature with markers
parameter. Check out demo here http://jvectormap.com/examples/markers-world/.
The jVectorMap world map uses the van der Grinten projection. The formula to convert from/to the map can be found this Wikipedia and Wolfram article.
You'll need to scale it to your map's size & offset, given the above formula projects the long/lat (-180 to 180 deg) to a (-1 to +1) cartesian grid.
Also, the angles in the formula should be in radians, not in degrees.
function vanDerGrinten(lat, lng) {
lat = lat * Math.PI / 180;
lng = lng * Math.PI / 180;
var lng0 = 0;
var A1 = 0.5 * Math.abs((Math.PI / (lng - lng0) - (lng - lng0) / Math.PI));
var phi = Math.asin(Math.abs(2 * lat / Math.PI));
var G = Math.cos(phi) / (Math.sin(phi) + Math.cos(phi) - 1);
P = G * (2 / Math.sin(phi) - 1);
Q = A1 * A1 + G;
x0 = A1 * A1 * (G - P * P) * (G - P * P) - (P * P + A1 * A1) * (G * G - P * P);
x1 = (A1 * (G - P * P) + Math.sqrt(x0));
x2 = (P * P + A1 * A1);
x = sgn(lng - lng0) * Math.PI * x1 / x2;
y = sgn(lat) * Math.PI * Math.abs(P * Q - A1 * Math.sqrt((A1 * A1 + 1) * (P * P + A1 * A1) - Q * Q)) / (P * P + A1 * A1);
return { _x: x, _y: y };
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With