Adding an onclick event to google.map marker

Make sure the marker is defined outside of initialize(). Otherwise, it will be undefined if you attempt to assign the click listener outside of initialize(). Also, you may have SAME-ORIGIN issues if you attempt to load url www.google.com, but it should work fine with a local url. Updated code var myCenter=new google.maps.LatLng(53, -1.33); var marker=new … Read more

Detecting Google Maps streetview mode

Detect the visible_changed event on the StreetViewPanorama associated with your Map object. You can get the panorama from the map by calling its getStreetView() method and bind the handler to that object’s event. You will have to test the StreetViewPanorama‘s visibility by calling its getVisible() method. For instance: var map = new google.maps.Map(document.getElementById(“theMap”), {streetViewControl: true}); … Read more

Google Maps API V3 not rendering competely on tabbed page using Twitter’s Bootstrap

I was battling with this issue as well. I was using a modal form and it rendered the map when it was hidden. When the tab is shown, you need to trigger this code: google.maps.event.trigger(map, ‘resize’); map.setZoom( map.getZoom() ); Hopefully it will work for you. If that doesn’t work, here is the link where I … Read more

how to change the color of route in google maps v3

You can specify the color of the line when you create the DirectionsRenderer, using the optional DirectionsRendererOptions struct. This works for me, simply changing the line where the DirectionsRenderer object is created: <!DOCTYPE html> <html> <head> <meta name=”viewport” content=”initial-scale=1.0, user-scalable=no”> <meta charset=”utf-8″> <title>Directions service</title> <link href=”https://google-developers.appspot.com/maps/documentation/javascript/examples/default.css” rel=”stylesheet”> <script src=”https://maps.googleapis.com/maps/api/js?v=3″></script> <script> var directionsDisplay; var directionsService = … Read more

Bounce a pin in google maps once

Bit of a simple approach: Google’s bounce animation appears to take exactly 750 ms for one cycle. Thus, simply set the timeout to 750 ms and the animation will stop exactly at the end of the first bounce. Works for me on FF 7, Chrome 14 and IE 8: marker.setAnimation(google.maps.Animation.BOUNCE); setTimeout(function(){ marker.setAnimation(null); }, 750);

Google Maps: display an encoded polyline

google.maps.geometry.encoding.decodePath(encodedPath:string) http://code.google.com/apis/maps/documentation/javascript/reference.html#encoding From that page: var decodedPath = google.maps.geometry.encoding.decodePath(encodedPolyline); var decodedLevels = decodeLevels(encodedLevels); // Decode an encoded levels string into an array of levels. function decodeLevels(encodedLevelsString) { var decodedLevels = []; for (var i = 0; i < encodedLevelsString.length; ++i) { var level = encodedLevelsString.charCodeAt(i) – 63; decodedLevels.push(level); } return decodedLevels; } Make sure the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)