I am trying to add multiple pinpoint to google map using Lon/Lat. All addresses will be fetched from mysql database using PHP.
I have looked at google and searched for it on various sites but nothing helpful i found.
i have used the following code which worked for only one address whereas i have alot of addresses.
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html>
- <html>
- <head>
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
- <title>Google Maps JavaScript API v3 Example: Geocoding Simple</title>
- <link href="http://code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
- <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
- <script type="text/javascript">
- var geocoder;
- var map;
- function initialize() {
- geocoder = new google.maps.Geocoder();
- var latlng = new google.maps.LatLng(-34.397, 150.644);
- var myOptions = {
- zoom: 8,
- center: latlng,
- mapTypeId: google.maps.MapTypeId.ROADMAP
- }
- map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
- }
- function codeAddress() {
- var address = 'Sydney, NSW';
- geocoder.geocode( { 'address': address}, function(results, status) {
- if (status == google.maps.GeocoderStatus.OK) {
- initialize();
- map.setCenter(results[0].geometry.location);
- /* var marker = new google.maps.Marker({
- map: map,
- position: results[0].geometry.location
- });*/
- var marker = new google.maps.Marker({
- position: new google.maps.LatLng+results[0].geometry.location,
- map: map,
- position: results[0].geometry.location,
- title:"Hello World!"});
- } else {
- alert("Geocode was not successful for the following reason: " + status);
- }
- });
- }
- </script>
- </head>
- <body onload="initialize();codeAddress();">
- <div id="map_canvas" style="height:90%"></div>
- </body>
- </html>
Thanking you.
Faisal