i have got these two coordinates x and y from an external database.
X = 30490, y = 31430
was trying to figure out how to plot these coordinates on to google map? As google map only accept lat and lon value...
Any help is most appreciated!! Thanks...
This may help.
How do I convert coordinates to a Latitude & Longitude?
You will need to know the coordinate system that was used for those coordinates. There are hundreds if not thousands of 'official' coordinate systems!
once you have the coordinate system, you can transform the coordinates to those used by Google (Longitude, Latitude degrees WGS84 with a spherical Earth).
You may want to do the transformation offline, but if you are doing it online with JavaScript, then take a look at the Proj4JS library.
For offline use, the standard open source library is Proj.4 but that is probably a bit daunting if this is your first experience with geographic coordinate systems and map projections.
Related
I got a set of wgs84 coordinates to place a polygon on Google Maps. I am wondering if i can use the same coordinates to get a compass direction of the coordinates. I don't need a solution specific for Google Maps, javascript or php. I am just wondering what the right approche would be.
Something like this would be the end result. I understand it needs some sort of algorithm in the background
I found Geolib and the 'getCompassDirection' function but this function only allows 2 points to create a line and get the bearing(angle) of that line.
You can't get any direction information out of a single position coordinate.
Position coordinates don't represent any knowledge about the orientation of an object. Therefore you need something that has direction (i.e. a vector between two coordinates) to calculate compass direction. That's exactly why the function you mentioned asks for two points.
This means you can get a compass direction for any edge of a polygon (by using its two end points), but not for its vertices.
Hope this helps!
I have an array of lat/lng. Example:
[
"14.60592,103.12081",
"38.21146,114.86461",
"13.73028,100.65138",
"34.08863,108.39783",
"57.186,14.04"
]
How can I calculate the overall distance from A to B and from B to C.
I trying with the Google Distance Matrix API.
If you need driving distance then you will not be able to calculate it with any formula not knowing the terrain, roads etc. For example if there is a river between those two points then the driving distance will depend on where is the closest bridge.
You can use some API that has that knowledge and can give you a real driving distance. For example you can use the Google Maps API. See e.g. Distance Matrix API:
https://developers.google.com/maps/documentation/distance-matrix/
https://developers.google.com/maps/documentation/distance-matrix/intro
You can use the Google Maps API in Node with:
https://www.npmjs.com/package/google-maps
https://www.npmjs.com/package/#google/maps
https://www.npmjs.com/package/googlemaps
and some more - see:
https://www.npmjs.com/browse/keyword/google-maps
I need a vector world map in JS/Flash that supports display of dots based on their lat/lon coordinates. I need to use this for a office locator, for a company with offices around the world. The idea is you click on the office in the list, and the map navigates to the dot of that office. Dots are displayed for all offices.
JVectorMap is built with JS, but does not support Lat/Lon, as far as I can see
SVG World Map is built with jQuery, but no Lat/Lon, it only supports clicking countries
This question (and this gist) uses D3 to draw a map possibly with Lat/Lon dots
Vis4 contains 100+ projections, and possibly supports lat/lon
GerbenRobijn has an equirect map with lat/lon support
How do I engineer a map to support Lat/Lon coordinates, and convert X/Y to Lat/Lon (convert mouse coordinates to Lat/Lon), and convert Lat/Lon to X/Y (convert Geo-marker to a dot on the map)
All of the decent map packages have a "Lat/Lon support". The help page for your first example, JVectorMap, describes two functions:
latLngToPoint
Converts coordinates expressed as latitude and longitude to the coordinates in pixels on the map.
pointToLatLng
Converts cartesian coordinates into coordinates expressed as latitude and longitude.
The 'setFocus' in the same package can accept either lat/lon or x, y coordinates.
I fail to see a problem.
I am developing an application via the Google Maps API (Version 3).
I have 2 google.maps.LatLng objects named loc1 and loc2.
How do I calculate the distance between them in say meters?
I have tried using various tricks from this question to convert latitude/longitude measures into meters. However, I question the reliability of my implementation.
I have also tried implementing a distance matrix, but I think that a distance matrix is a lot of work just to calculate the distance between 2 points.
Thank you!
Sounds simple, I recommend the geometry library,
https://developers.google.com/maps/documentation/javascript/reference#spherical
computeDistanceBetween(from:LatLng, to:LatLng, radius?:number)
From my experience the result is in meters. Remember to add the optional geometry library in your tag
<script type="text/javascript"
src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false">
</script>
Calculating distances between two points basically boils down to pythagoras (sum of the squares etc). However, this doesn't really work with Lat & Lon (which are coordinates on a sphere). What I do is convert the Lat & Lon values to the local map grid which is flat. Then I can use pythagoras to calculate the distance between those points. I've already posted on this in Stack Overflow here. This will have all the code you would need.
Your question is a bit ambiguous.
I mean - when you say the distance, do mean
distance in a straight line
or driving distance,
or bicycle distance,
or walking distance.
The answer to this question will determine your implementation.
If it is a straight line distance you need, then it is best to use the haversine implementation.
Otherwise, you will need to request directions from the google directions service, specifying the mode of "transport".
When you've finished you can test the distance between two points on a straight line using the provided map. It will give you a visual as well as the distance.
I want to create a data visualization similar to this:
...but for the entire globe. The canvas size will be arbitrary but won't need to resize with the browser (I will set the width and height before I start plotting points). I need to figure out a way of converting latitude and longitude coordinates to points on the canvas. Does anyone know how to do it?
First of all you need to choose projection. Then you can use proper formula. Or you can just use existent solution like proj4js for example. This is JS port of well-known proj utility for working with various projections.
I would recommend to use Miller Projection for the visualizations on the whole globe. You can find formulas here.