返回顶部

收藏

JS通过google api(3.0)调用google地图

更多
<div id="map-canvas" style="height:400px"></div>

<script>
function initialize() {

  var myLatlng = new google.maps.LatLng(52.372645,-1.27442); // Add the coordinates
  var mapOptions = {
    zoom: 8, // The initial zoom level when your map loads
    minZoom: 6, // Minimum zoom level allowed
    maxZoom: 17, // Maximum soom level allowed
    center: myLatlng, // Centre the Map on your coordinates
    mapTypeId: google.maps.MapTypeId.ROADMAP, // Set the type of Map
    mapTypeControl:false // Disable Satellite switch
  }

  var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

  // Create a variable for our marker image.
  var image = new google.maps.MarkerImage("custom-heat-pin.png", null, null, null, new google.maps.Size(111,69));
  // For retina compatibility, create your image at twice the resilution you specify for the size above.

  // Set the marker
  var marker = new google.maps.Marker({
      position: myLatlng, // Position to your coordinates.
      // animation:google.maps.Animation.BOUNCE, // Enable for the bouncing marker animation
      icon:image, //use our image as the marker
      map: map, // assign the market to our map
      title: 'Click to visit our company on Google Places' // Marker ALT Text
  });

    google.maps.event.addListener(marker, 'click', function() {
            window.location='http://www.creare.co.uk/'; // URL to Link Market to (i.e Google Places Listing)
        });

    }

google.maps.event.addDomListener(window, 'load', initialize);

</script>

标签:谷歌地图,google,map,api

收藏

0人收藏

支持

0

反对

0

发表评论