BrU32

JS Google Maps Geolocation Gen Final Revised W\ Fast Zoom

Aug 6th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script
  5. src="http://maps.googleapis.com/maps/api/js">
  6. </script>
  7. <script>
  8. var myCenter=new google.maps.LatLng(Math.random()*89.0000,Math.random()*1119.0000);
  9. function initialize()
  10. {
  11. var mapProp = {
  12. center: myCenter,
  13. zoom:5,
  14. mapTypeId: google.maps.MapTypeId.HYBRID
  15. };
  16. var map = new google.maps.Map(document.getElementById("googleMap"),mapProp);
  17. var marker = new google.maps.Marker({
  18. position: myCenter,
  19. title:'Click to zoom'
  20. });
  21. marker.setMap(map);
  22. google.maps.event.addListener(marker,'click',function() {
  23. map.setZoom(15);
  24. map.setCenter(marker.getPosition());
  25. });
  26. google.maps.event.addListener(marker,'dblclick',function() {
  27. map.setZoom(5);
  28. map.setCenter(marker.getPosition());
  29. });
  30. }
  31. google.maps.event.addDomListener(window, 'load', initialize);
  32. </script>
  33. </head>
  34. <body>
  35. <div id="googleMap" style="width:500px;height:380px;"></div>
  36. </body>
  37. </html>
Add Comment
Please, Sign In to add comment