Google Map icon (pin) - how to define color?

耗尽温柔 提交于 2019-12-07 04:11:51

问题


is it possible to change color of pin placed on google map creatted by it's api? or have to use custom icon to do that?

it's google map api v3.

tnx in adv!


回答1:


You can declare the image when you initialize the map:

var overlay;

function initialize() {
  var myLatLng = new google.maps.LatLng(0, 0);
  var myOptions = {
    zoom: 11,
    center: myLatLng,
    mapTypeId: google.maps.MapTypeId.SATELLITE
  };

  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  var swBound = new google.maps.LatLng(0, 0);
  var neBound = new google.maps.LatLng(0, 0);
  var bounds = new google.maps.LatLngBounds(swBound, neBound);

  // This is where you declare your image...
  var srcImage = 'images/yourimage.png';
  overlay = new USGSOverlay(bounds, srcImage, map);
}

More info here if you need it:

http://code.google.com/apis/maps/documentation/javascript/overlays.html#CustomOverlays



来源:https://stackoverflow.com/questions/3948763/google-map-icon-pin-how-to-define-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!