Google map driving direction source code for their example?

Here’s a very basic example using the v3 API: <!DOCTYPE html> <html> <head> <meta http-equiv=”content-type” content=”text/html; charset=UTF-8″/> <title>Google Maps API v3 Directions Example</title> <script type=”text/javascript” src=”http://maps.google.com/maps/api/js?sensor=false”></script> </head> <body style=”font-family: Arial; font-size: 12px;”> <div style=”width: 600px;”> <div id=”map” style=”width: 280px; height: 400px; float: left;”></div> <div id=”panel” style=”width: 300px; float: right;”></div> </div> <script type=”text/javascript”> var directionsService = … Read more

How to check if Google Street View available and display message?

In v3 this has changed a bit. Check out the documentation at http://code.google.com/apis/maps/documentation/javascript/reference.html#StreetViewService The updated code is: var streetViewService = new google.maps.StreetViewService(); var STREETVIEW_MAX_DISTANCE = 100; var latLng = new google.maps.LatLng(40.7140, -74.0062); streetViewService.getPanoramaByLocation(latLng, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) { if (status === google.maps.StreetViewStatus.OK) { // ok } else { // no street view available in this … Read more

Looping through Markers with Google Maps API v3 Problem

You are having a very common closure problem in the following loop: for(x in locations){ console.log(x); infowindow[x] = new google.maps.InfoWindow({content: x}); marker[x] = new google.maps.Marker({title:locations[x][0],map:map,position:locations[x][2]}); google.maps.event.addListener(marker[x], ‘click’, function() {infowindow[x].open(map,marker[x]);}); } Variables enclosed in a closure share the same single environment, so by the time the click callbacks are executed, the loop has run its course … Read more

google maps iOS SDK: custom icons to be used as markers

Here is what I have done let marker = GMSMarker() // I have taken a pin image which is a custom image let markerImage = UIImage(named: “mapMarker”)!.withRenderingMode(.alwaysTemplate) //creating a marker view let markerView = UIImageView(image: markerImage) //changing the tint color of the image markerView.tintColor = UIColor.red marker.position = CLLocationCoordinate2D(latitude: 28.7041, longitude: 77.1025) marker.iconView = markerView … Read more

Show popup above map marker in MapView

The way I did is: Put the markers at required GeoPoints by subclassing ItemizedOverlay, as described in http://developer.android.com/guide/tutorials/views/hello-mapview.html Create a popup View by inflating from the layout: View popUp = getLayoutInflater().inflate(R.layout.map_popup, map, false); Use MapView.LayoutParams to position the popup with respect to GeoPoint in the ItemizedOverlay< OverlayItem >::onTap method. Popup will scroll automatically (without any … Read more

GoogleMaps v3 API Create only 1 marker on click

var marker; function placeMarker(location) { if ( marker ) { marker.setPosition(location); } else { marker = new google.maps.Marker({ position: location, map: map }); } } google.maps.event.addListener(map, ‘click’, function(event) { placeMarker(event.latLng); }); You have to work on the same marker all the time – do not create new ones. Here you have a global variable marker … Read more