jquery google map init


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <script src="http://maps.google.com/maps?file=api&v=2&key=ApiKeyinizBurayaYazılacak&sensor=true"
  2. type="text/javascript"></script>
  3.  
  4. <script type="text/javascript">
  5. var geocoder;
  6. var map;
  7. function initialize() {
  8. var geocoder = new GClientGeocoder();
  9. var map = new GMap2(document.getElementById("map_canvas"));
  10. geocoder.getLocations("Istanbul , TURKEY", function(result){
  11. if (result.Status.code != 200) {
  12. alert('Could not geocode "' + result.name + '"');
  13. return;
  14. }
  15. place = result.Placemark[0];
  16. point = new GLatLng(place.Point.coordinates[1],
  17. place.Point.coordinates[0]);
  18. map.setMapType(G_HYBRID_MAP);
  19. map.setCenter(point, 8);
  20. marker = new GMarker(point);
  21. map.addOverlay(marker);
  22. alert("OK");
  23. marker.openInfoWindowHtml(place.address);
  24.  
  25. });
  26.  
  27. }
  28.  
  29. $(document).ready(function(){
  30. initialize();
  31. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.