frizi Posted November 3, 2010 Share Posted November 3, 2010 Hi, would be great if you could help with the following code. It should put a marker on the map regarding the found place. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps API Example: Simple Geocoding</title> <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjU0EJWnWPMv7oQ-jjS7dYxSPW5CJgpdgO_s4yyMovOaVh_KvvhSfpvagV18eOyDWu7VytS6Bi1CWxw" type="text/javascript"></script> <script type="text/javascript"> function first_run(){ map_from = new GMap2(document.getElementById("map_canvas_from")); map_to = new GMap2(document.getElementById("map_canvas_to")); map_from.setCenter(new GLatLng(48.7209956,21.2577477), 2); map_from.setUIToDefault(); map_to.setCenter(new GLatLng(48.7209956,21.2577477), 2); map_to.setUIToDefault(); } function showAddress(address,element_id){ map = new GMap2(document.getElementById("map_canvas_"+element_id)); map.setUIToDefault(); geocoder = new GClientGeocoder(); geocoder.getLocations(address, addToMap); } function addToMap(response){ //delete marker; //place=NULL; //point=NULL; place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]); change_text(point); marker = new GMarker(point,{draggable: false}); marker.openInfoWindowHtml(marker.getLatLng().toUrlValue(6)+' '+place.address); map.addOverlay(marker); map.setCenter(point, 10); } function change_text(text){ var txt=document.getElementById("info"); txt.innerHTML=text; } </script> </head> <body onload="first_run()" onunload="GUnload()"> <form action="#"> <input type="text" style="width:350px" name="address_from" value="" /> <a href="" onclick="showAddress(address_from.value,'from'); return false;" >find from</a> <div id="map_canvas_from" style="width: 600px; height: 500px"></div><br/><br/> <input type="text" style="width:350px" name="address_to" value="" /> <a href="" onclick="showAddress(address_to.value,'to'); return false;" >find to</a> <div id="map_canvas_to" style="width: 600px; height: 500px"></div> </form> <a href="#" onclick=" change_text('cleared');">click</a> <div id="info">Info</div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/217711-google-api-the-next-markers-are-not-displayed/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.