Google Map图标(pin) - 如何定义颜色? [英] Google Map icon (pin) - how to define color?

查看:158
本文介绍了Google Map图标(pin) - 如何定义颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改通过api创建的Google地图上的徽标颜色?或者必须使用自定义图标来做到这一点?



它是google map api v3。



tnx in adv!

解决方案

您可以在初始化地图时声明图像:

  var overlay; 

函数initialize(){
var myLatLng = new google.maps.LatLng(0,0);
var myOptions = {
zoom:11,
center:myLatLng,$ b $ 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);

//这是您声明图片的位置...
var srcImage ='images / yourimage.png';
overlay = new USGSOverlay(bounds,srcImage,map);

$ / code>

更多信息如果您需要它:



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

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!

解决方案

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

这篇关于Google Map图标(pin) - 如何定义颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆