anujgarg Posted September 23, 2008 Share Posted September 23, 2008 I am trying to pinpoint the exact location in Google map. All I am doing is this: <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAANrkYWsr17H4qwp8F1mvNyxTm-bDTxsIOQzi66Vw1ZLvF-ZFr6hRSYJmOZ1HDVQFC32OU4aDTRSbfHA" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); } } //]]> </script> </head> <body onload="load()" onunload="GUnload()"> <div id="map" style="width: 500px; height: 300px"></div> </body> But this code is not able to pinpoint the exact location in map. This is just showing simple map. I want a map like this: http://gmaps-samples-flash.googlecode.com/svn/trunk/examples/MapInfoWindow.html How can I do this? Link to comment https://forums.phpfreaks.com/topic/125427-pinpoint-in-google-map/ Share on other sites More sharing options...
mark110384 Posted September 23, 2008 Share Posted September 23, 2008 This has been tested and works you just need to use your own custom marker, it works on a mouse over event. <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAANrkYWsr17H4qwp8F1mvNyxTm-bDTxsIOQzi66Vw1ZLvF-ZFr6hRSYJmOZ1HDVQFC32OU4aDTRSbfHA" type="text/javascript"></script> <body onload="buildMap()" onunload="GUnload()"> <div id="map" style="width: 500px; height: 300px"></div> <script type="text/javascript"> function buildMap() { var icon = new GIcon(); icon.image = "../images/blue_marker.png"; //Put your custom image for a marker here! icon.iconSize = new GSize(18, 18); icon.iconAnchor = new GPoint(8, ; icon.infoWindowAnchor = new GPoint(5, 1); function createMarker(point,html) { var marker = new GMarker(point,icon); GEvent.addListener(marker, "mouseover", function() { marker.openInfoWindowHtml(html); }); return marker; } var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(37.4419, -122.1419), 13); var point = new GLatLng(37.4419, -122.1419); var label = '<div style="width:240px"><font face="Lucida Sans">Hello World</font></div>' var marker = createMarker(point, label) map.addOverlay(marker); } </script> <noscript>Your Browser does not support this application. Please switch on JavaScript to view this Google maps</noscript> </body> Link to comment https://forums.phpfreaks.com/topic/125427-pinpoint-in-google-map/#findComment-648685 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.