Get latitude and Longitude of animated symbol on polyline - google-maps

I have a map with a polyline and an animated symbol on the line. Just like the example that Google have here
https://developers.google.com/maps/documentation/javascript/examples/overlay-symbol-animate
Now I want to extract latitude and longitude of the animated symbol as it animates. I want to pan the map to the symbol so if the symbol is out of bound, the map automatically adjusts it self to show the animated symbol.
If there is any other work around to do this rather than getting the lat long points, do tell me.

I am not sure there is a latlng object available for the symbol.
By looking at the line object in the example you provided, it looks like only the offset attribute can be accessed.
However, you can compute the position of the symbol from this value:
Example: http://jsfiddle.net/ZPkMq/
If your polyline is not a straight line, finding the position of the symbol may be slightly more complex (but doable - see place marker on polyline with specific distance)

The thing is you can't get the LatLng point from the animated symbol. I just discarded using the symbol and started using marker to animate along a polyline. This gives a lot more options, and you can do almost anything.

Related

How to zoom a leaflet map depending on the latitude and longitude

I want to show a popup window where i am going to show a leaflet map. In the popup window i'll show the path between two points. These two points are two [lat,lon] pairs
Point A is [lata,lona], Point B is [latb,lonb]. I want to set the view or or zoom level of the map so that the map is zoomed focusing the distance between point A and Point B. That means the map will have point A at near of one end of the map and point B at near of other end of the map. How can I do it. I am now using the following command to setview to to Point A and point A remains at middle. Here is my command
map.setView([A[0],A[1]],14);
So the point A is at the middle but the point B sometimes go even outside map. I want both A and B to be shown at map and the farthest distance within the map.
Use the fitBounds method instead of setView if you want to focus the map to an area rather than a point.

Change Google Maps direction line to icons

Is there a way to change the default Google Maps direction line, the blue line that you are meant to follow, into a series of icons?
So instead of having a blue line showing the route on the map, I'd like to replace this with a series of small icons.
Or, if that isn't possible, can I place icons along the route in say 1km increments?
I see plenty of examples of replacing the start and end markers but not of the line.
Yes, it is possible. One option:
PolylineOptions to the DirectionsRenderer, you can also apply symbols to the Polyline
(example using a "dash" symbol)
or extract the route data and use it to put icons at all the vertices on the polyline (like the answer to this question, but with a transparent polyline)
example of a custom DirctionsRenderer
markers every 2km on a Polyline
markers at 2 arbitrary distances on a directions polyline

algorith or formula to get a set of lat lon values based on viewport and zoomlevel

I need to display around 50,000 markers on the map. But i was able to plot only 10000 points. I thought of implementing this way correct me if i'm wrong...
Instead of fetching whole data at once just fetch points that are in the viewport and depending on the zoomlevel.
ex:google maps: at one zoomlevel only states are shows if we zoom in further cities are shown
I'm stuck with the zoomlevel.. how to relate zoomlevel and viewport.Is there any algorithm or formulae that helps in getting the lat long values or it needs to be hardcoded in the database like for particular lat-lon this is the zoomlevel range so while fetching range is checked.
i'm using openlayers bbox feature to get the bounds
Thanx in advance
google.maps.Map.getBounds() will return the lat/long bounds of the viewport.
50,000 markers is a lot compared to what Google Maps can handle; you would have to be way zoomed in to have few enough markers to be under the limits. You might do better by creating custom tiles with dots instead of markers. You can see an example at
http://maps.webfoot.com/demos/election2008/
Scroll down to the third overlay to see dots; select zip codes to see LOTS of dots.

KML coordinates are off in a custom Google Map?

EDIT: Turns out it was all because the coordinate translation functions in the javascript were written wrong. The author of the program has apparently fixed it.
I'm trying to use KML files to display placemarks on a custom Google Maps map. The map was generated by a Minecraft mapping program called Unmined.
My problem lies with the positioning of placemarks. They are placed on the map in a position that doesn't seem to correlate with either the pixel or latitude/longitude coordinates of the map itself.
Here is an image showing my problem.
I loaded a KML with five placemarks defined. One in the middle (0,0), one in the top-left corner (-170,80), one in the top-right corner (170,80), one in the bottom-left corner (-170,-80), and one in the bottom-right corner (170,-80). The set of markers seems to be duplicated horizontally but from my experience that's standard with Google Maps. As far as I know, the range of valid coordinates in a KML file are from -180 to 180 longitude and -90 to 90 latitude, which means that any valid placemark would have to fall somewhere inside that rectangle. Except that rectangle barely intersects the map at all.
If you need access to the code I'm using, everything can be found in the source of http://tonyfox.ws/dt/kantomap/ (URL may not exist forever)
So am I just doing something catastrophically wrong or what?
On a related note, how does Google Maps decide where to place the map in the coordinate system when the map isn't an actual Earth map (like this Minecraft world map)? My map seems to range from about 14.5 to 19.5 longitude, and 25.5 to 28 latitude. Why such weird numbers?

Draw area/polygon and retrieve coordinates with google maps

Is there any tool that can help me with getting the coordinates for a specific area/polygon?
I usually use Google Earth.
Draw a polygon, then move the mouse over and right click > copy.
Then you can paste it in the notepad and you will find the coordinates there (remeber the format (long, lat,n) the reverse of Google Maps format.
You can also use online tools to format the information or remove parts.
http://www.earthpoint.us/Shapes.aspx
So the idea is to have a map, draw a polygon on it (I assume by placing the vertexes) and then getting the coordinates of the vertexes?
You can make markers draggable when you create then. You can also get the lat/lng position of the markers when certain events fire: the 'dragend' event, for instance.
With these tools, you have the basics of your requirements here. Make a button that places vertexes on the map - just use a marker with custom graphics - and let the user drag the vertex to whatever position they need. Record the new position of the vertex whenever the dragend event fires. Draw lines on the map between the markers, to show to the user the area selected. Have a button to 'complete' the shape, linking the last vertex up with the first vertex.
There may be some existing code to do this, but I am not aware of it. However, it should be possible to throw something together with a bit of work.