Hi! I'm trying to get a map to show markers which have their values (response.Placemark[0]) in an array. The reason I want this value in an array is to make things easier for me. I think the values are placed inside the array and I Guess the way I read them FROM the array is right too but the process of creating a marker (which works in a different file) doesn't work this way. If anyone has any ideas on how to get this working, please share :)
Here's my code in <head>: <script src="http://maps.google.com/maps? file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1- m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></ script> <script type="text/javascript"> var map; var geocoder; var markerArray = new Array(); function initialize() { map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GLargeMapControl()); map.enableScrollWheelZoom(); geocoder = new GClientGeocoder(); findLocation('Sperberweg 6a, 41468 Neuss'); findLocation('Dreifelderstrasse 46, 70599 Stuttgart'); findLocation('Heidelbergstr. 6, 07554 Korbussen'); findLocation('Herzbergstr. 87, 10365 Berlin'); point = new GLatLng(50,50); map.setCenter(point,5); for(i in markerArray) { var place = markerArray[i]; point = new GLatLng(place.Point.coordinates [1],place.Point.coordinates[0]); marker = new GMarker(point); GEvent.addListener(marker, "mouseover", function() {map.closeInfoWindow();address = place.address;this.openInfoWindowHtml (place.address);}); GEvent.addListener(marker, "mouseout", function() {map.closeInfoWindow();}); map.addOverlay(marker); } } function addAddressToMap(response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode that address"); } else { markerArray.push(response.Placemark[0]); } } function findLocation(address) { geocoder.getLocations(address, addAddressToMap); } </script> And this is the rest: <body onload="initialize()" onunload="GUnload()"> <div id="map_canvas" style="width:400px; height:300px;"></div> </body> The other code I made which I was referring to is this: <!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"/ > <script src="http://maps.google.com/maps? file=api&v=2.x&key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1- m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></ script> <script type="text/javascript"> var map; var geocoder; var smallestLat; var largestLat; var smallestLng; var largestLng; function initialize() { map = new GMap2(document.getElementById("map_canvas")); geocoder = new GClientGeocoder(); findLocation('Sperberweg 6a, 41468 Neuss'); findLocation('Dreifelderstrasse 46, 70599 Stuttgart'); findLocation('Heidelbergstr. 6, 07554 Korbussen'); findLocation('Herzbergstr. 87, 10365 Berlin'); map.addControl(new GLargeMapControl()); map.enableScrollWheelZoom(); //map.addControl(new GMapTypeControl()); } function addAddressToMap(response) { if (!response || response.Status.code != 200) { alert("Sorry, we were unable to geocode that address"); } else { var place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); map.setCenter(point,6); marker = new GMarker(point); GEvent.addListener(marker, "mouseover", function() { map.closeInfoWindow(); address = place.address; this.openInfoWindowHtml(place.address); }); GEvent.addListener(marker, "mouseout", function(){ map.closeInfoWindow(); }); map.addOverlay(marker); } } // findLocation() is used to enter the sample addresses into the form. function findLocation(address) { geocoder.getLocations(address, addAddressToMap); } </script> </head> <body onload="initialize()" onunload="GUnload()" style="height: 100%;margin:0px;"> <div id="map_canvas" style="width:800px; height: 600px;float:left;"></div> </body> </html> this is a completely working file. the api key is the demo key from google so it only works on a local computer, not on a website yet. Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
