Google map API
I have seen many queries about the google map problems like,
-Display Multiple Markers in Array - Google Maps API
-Multiple markers not showing in Google Maps with Javascript API v3?
- etc...
I have completed the google api with array of the location. I have tried this and is good.
here is the code:
<script type="text/javascript">var map;var markers = [];var data = [{id:"1",name:"Sujan Bhochhibhoya",address:"KATHMANDU, NEPAL"},{id:"3",name:"David Beckham",address:"LONDON, UNITED KINGDOM"},{id:"4",name:"KOBE BRYAN",address:"Los Angeles, California, United States"}];function initialize(){var latlng = new google.maps.LatLng(0, 0);var myOptions = { zoom: 2,minZoom:2,zoomControl: true,zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE, },center: latlng};map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);geocoder = new google.maps.Geocoder();data.forEach(function(mapData,idx) { geocoder.geocode( { 'address': mapData.address},function(results, status) {if (status == google.maps.GeocoderStatus.OK) {var markers = new google.maps.Marker({map: map,position: results[0].geometry.location,title: mapData.address,draggable: false,visible: true});}});});} </script>
Here I have used associative array to make completed solution.
For more problem regarding google map api with infobox style, you will get it in my next article
Comments
Post a Comment