Can I draw a straight line in Google Maps? - google-maps

Is there an API I can use to draw a straight line between two points in a Google map, and to show the line in different colors?
Example: draw a straight line between NYC and Los Angeles with green or red line?

Yes. Have you checked out the Google Maps APIs?
For example check out the source code for this example

Check this out, http://www.birdtheme.org/useful/v3tool.html. This application uses the Google Maps API Version 3 (V3). When you draw the line between two cities, this tool will auto generate kml or javascript code for you, and you can import it into your website and load the map

Using Polylines, you can draw a straight line.
You can see an example here

This worked for me. With the method mentioned here I was able to draw polylines on Google Maps V2. You can easily change color and width of these polylines. I drew a new line whenever the user location got changed, so the the polyline looks like the path followed by user on map.
Source code at. Github Repository: prasang7/eTaxi-Meter
Please ignore other modules of this project related to distance calculation and User Interface if you are not interested in them.

Related

Google Maps: Draw polygon surrounding random locations

I have a set of random locations. The location set will keep changing. I would like to draw a polygon surrounding these locations.
Can this be done in Google Maps and how? The map will be displayed on a website only, no mobile api required.
It's called a convex hull. Here:
http://www.geocodezip.com/v3_map-markers_convexhull.asp
I would cite the code but it belongs to #geocodezip who is the authority on google maps and runs an excellent site of examples. I suggest you check it out.

Mapbox or Google Maps. Is this possible?

I have a custom map from a client. They want to either use Mapbox or google maps to add markers to it. The problem is they've customized how the world map actually looks. It doesn't show on the map image attached, but they cut off Alaska, and want to show it directly under Texas as a floating state. They also want to show so other states in an odd order. To the right of Alaska they want Hawaii, Puerto Rico, US Virgin Islands.
Two issues here:
1) Can this be done? I can't find any information about cutting pieces of a map up by moving states around.
2) If I CAN do this, will the geocoding still work for the map? Cause now Alaska is way the heck down there.
As far as I know, yes to both of your issues.
Now, to answer your issues:
1) Can this be done? I can't find any information about cutting pieces of a map up by moving states around.
As discussed in Translate your project from Google to Mapbox, you have options to customize maps and features. Then, any customized project created in the Mapbox Editor or uploaded from Mapbox Studio Classic will have a Map ID. Use the Map ID when initializing the map to add it as the active layer.
2) If I CAN do this, will the geocoding still work for the map? Cause now Alaska is way the heck down there.
Yes, geocoding will still work. With Mapbox, L.mapbox.geocoder() will gladly geocode your addresses.
Please try going through the given documentation for more information and for sample codes. Hope that helps!

Draw route from lat/lng list in SAPUI5

I´m using the framework openui5-googlemaps for using google maps in a sapui5 application.
I have an array of lat/lng positions. I want to draw a line from position to position in this array.
I found an example with directions:
<gmaps:directions>
<gmaps:Directions startAddress="{mapModel>/start}" endAddress="mapModel>/end}" unitSystem="1" waypoints="{mapModel>/stops}">
<gmaps:waypoints>
<gmaps:Waypoint location="{mapModel>/name}"></gmaps:Waypoint>
</gmaps:waypoints>
</gmaps:Directions>
</gmaps:directions>
The problem on this solution is, that I don´t want a marker on each position.
(My positions have a distance of a few metres.)
Further this solution draws the lines based on the streets. I need a solution regardless of streets.
If you want to see example using Polylines see Sample App2
Let me know if you want an standalone example by adding an issue to the repo
[UPDATE]
here is a sample app using polylines
<openui5.googlemaps:Map id="map1" lat="{/beaches/1/lat}" lng="{/beaches/1/lng}" >
<openui5.googlemaps:polylines>
<openui5.googlemaps:Polyline path="{/beaches}" />
</openui5.googlemaps:polylines>
</openui5.googlemaps:Map>
running looks like

How to get KML of route with waypoints?

I need to draw routes in my android app's MapView and to do so I'm using the coordinates listed in the KML output file of Google Maps.
The problem is: when I add a waypoint to a route, the KML file doesn't contain the complete route details and only shows the coordinates/directions from the source to the waypoint.
Here is an example. As you can see, the route is drawn correctly and all the directions are shown, but the KML output only has the details from the source to waypoint.
A solution is making two requests, one for source->waypoint and other for waypoint->destination, but I would like to avoid that if possible.
Thanks.
Multistep routing is only supported in google maps directly.
See
http://groups.google.com/group/kml-support-advanced/browse_thread/thread/1d57c9f0bc879141
and
http://groups.google.com/group/kml-support-getting-started/msg/e3d15213ac4ae9ed

Google Maps - Online Map Marker to mark polygons and shapes onto the map

I'm looking looking for a tool that will allow me to make a map exactly like this:
http://datasearch.uts.edu.au/about/mapsdirections/map.cfm
Basically I need to put shapes around buildings in the satellite view and then slap a marker and information window on them so that I can specify the building name and contents.
So the main issue is that I need the ability to draw shapes directly onto the maps as I don't fancy taking down the lat lng of each corner of the polygon.
Ideally what I'd like to do is have an online application that exports those points to KML, and then I would display google maps on my site and import that kml to display it.
Other suggestions welcome!
Jason
Found a polygon creator
http://www.the-di-lab.com/polygon/
It's simple to use and allows you to copy and paste straight into your code. Would be nice if it had a button that said sent to kml though..