Google Map Geocoder probelm

Google Map Geocoder probelm

Postby Romeo » Tue Nov 22, 2016 10:09 pm

Hi

I have modified the following HTML example to show a Map with Addresses, but i cannot resolve the problem to have on the the marker the same address !
I'am not pratic of HTML.....any help to solve the problem ? Thansk any




++++++++ HTML EXAMPLE ****

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>WikiHow Geocode</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">

var loca = [
['Label Lomellina 7' , 'Via Lomellina 7, Milano'],
['Label Lomellina 13', 'Via Lomellina 13, Milano'],
['Corsica 64' , 'Viale Corsica 64,Milano'],
];

function initialize() {

//Set the geocoder variable equal to an instance of the google maps geocoder object as new google.maps.Geocoder()
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(42.095287, -79.3185139);
var myOptions = {
zoom: 16,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP

};

var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

setMarkers(map,loca);


}

function setMarkers(map,loca){
var i,marker
for (i = 0; i < loca.length; i++)
{
var sdes = loca[i][0]
var sAddress = loca[i][1]

geocoder.geocode( { 'address': sAddress}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map, title: sdes, position: results[0].geometry.location
});

map.setCenter(marker.getPosition())


content= sAddress;

var infowindow = new google.maps.InfoWindow()

google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){
return function() {
infowindow.setContent(content);
infowindow.open(map,marker); };
})(marker,content,infowindow));


} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}

</script>
</head>

<body onload="initialize()">
<div>
<div style="float:Left;">
<script type="text/javascript"><!--
google_ad_client = "pub-1830327498013415";
google_ad_slot = "7106425745";
google_ad_width = 160;
google_ad_height = 600;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
<div>

<div id="map_canvas" style="width:900px; height:600px"></div>
</div>
</div>
</body>
</html>

**** END OF HTML EXAMPLE ***
Romeo
 
Posts: 340
Joined: Thu Jan 25, 2007 3:53 pm
Location: Milan (Italy)

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 9 guests