Created
April 20, 2016 10:34
-
-
Save hsleonis/d6965f8229d65b12130ca567917a0b2d to your computer and use it in GitHub Desktop.
Google map markers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type='text/javascript' src='http://maps.google.com/maps/api/js?sensor=false'></script> | |
| <script type='text/javascript'> | |
| // <![CDATA[ | |
| var Mymap; | |
| var geocoder; | |
| var Latlng; | |
| var Options; | |
| var image; | |
| var cx = 0; | |
| var cy = 0; | |
| var tx = 0; | |
| var ty = 0; | |
| var gflg = 0; | |
| var iflg = 1; | |
| var address = new Array(20); | |
| var platlng = new Array(20); | |
| var Mymarker = new Array(20); | |
| var info = new Array(20); | |
| var mfile = new Array(20); | |
| address[1] = ''; | |
| platlng[1] = new google.maps.LatLng(23.751177, 90.390587); | |
| mfile[1] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[2] = ''; | |
| platlng[2] = new google.maps.LatLng(23.780932, 90.423098); | |
| mfile[2] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[3] = ''; | |
| platlng[3] = new google.maps.LatLng(23.799225, 90.354549); | |
| mfile[3] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[4] = ''; | |
| platlng[4] = new google.maps.LatLng(23.739211, 90.383092); | |
| mfile[4] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[5] = ''; | |
| platlng[5] = new google.maps.LatLng(23.738639,90.390677); | |
| mfile[5] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[6] = ''; | |
| platlng[6] = new google.maps.LatLng(23.736881, 90.414311); | |
| mfile[6] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[7] = ''; | |
| platlng[7] = new google.maps.LatLng(23.752140,90.420011); | |
| mfile[7] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[8] = ''; | |
| platlng[8] = new google.maps.LatLng(23.813544, 90.424341); | |
| mfile[8] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| address[9] = ''; | |
| platlng[9] = new google.maps.LatLng(23.763652, 90.359471); | |
| mfile[9] = 'http://www.grameenuniqlo.com/shared/imgs/store/marker.png'; | |
| function initialize(){ | |
| Options = { | |
| zoom: 12, | |
| center: new google.maps.LatLng(0,0), | |
| mapTypeId: google.maps.MapTypeId.ROADMAP | |
| } | |
| Mymap = new google.maps.Map(document.getElementById('map'), Options); | |
| geocoder = new google.maps.Geocoder(); | |
| document.getElementById('map').style.width = '100%'; | |
| document.getElementById('map').style.height = '297px'; | |
| for(i=1 ;i<20 ;i++){ | |
| if (address[i] == null){ | |
| break; | |
| } else { | |
| marking(i); | |
| } | |
| } | |
| } | |
| function marking(id) { | |
| geocoder.geocode( {'address': address[id]}, function(results, status) { | |
| if (gflg == 1 && status != google.maps.GeocoderStatus.OK) { | |
| marking(id); | |
| } | |
| if (gflg == 1 && status == google.maps.GeocoderStatus.OK) { | |
| Latlng = results[0].geometry.location; | |
| } | |
| if (gflg == 0) { | |
| Latlng = platlng[id]; | |
| } | |
| image = new google.maps.MarkerImage(mfile[id], | |
| new google.maps.Size(50,46), | |
| new google.maps.Point(0,0), | |
| new google.maps.Point(13,43), | |
| new google.maps.Size(50,46) | |
| ); | |
| Mymap.setCenter(Latlng); | |
| Mymarker[id] = new google.maps.Marker({ | |
| map: Mymap, | |
| position: Latlng, | |
| icon: image | |
| }); | |
| ty = ty + Latlng.lat(); | |
| tx = tx + Latlng.lng(); | |
| if (address[eval(id+1)] == null){ | |
| cy = ty/id; | |
| cx = tx/id; | |
| Mymap.setCenter(new google.maps.LatLng(cy,cx)); | |
| } | |
| google.maps.event.addListener(Mymarker[id], 'click', function() { | |
| for(j=1 ;j<20 ;j++){ | |
| if (info[j] != null && iflg == 1){ | |
| info[j].close(); | |
| } | |
| } | |
| info[id] = new google.maps.InfoWindow({ | |
| content: address[id] +'<br>'+ sname[id], | |
| maxWidth: 500 | |
| }); | |
| info[id].open(Mymap,Mymarker[id]); | |
| }); | |
| }); | |
| } | |
| jQuery(document).ready(function(){ | |
| initialize(); | |
| }); | |
| // ]]> | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment