带有标签的Google地图V3标记 [英] Google Maps V3 marker with label

查看:98
本文介绍了带有标签的Google地图V3标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  map.gmap(

如何将标签添加到我的标记中如果我的标记在ajax成功填充每个结果。 'addMarker',{'position':new google.maps.LatLng(result.latitude,result.longitude)});

我试过这样,但没有成功:

  map.gmap('addMarker',{
'position':new google.maps.LatLng(result.latitude,result.longitude),
'bounds':true,
'icon':markerIcon,$ b $'labelContent':'A',
'labelAnchor':new google.maps.Point(result.latitude,result.longitude ),
'labelClass':'labels',//标签的CSS类
'labelInBackground':false
});


解决方案

我怀疑标准库支持这一点。



但您可以使用Google地图实用程序库: b

http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries#MarkerWithLabel

  var myLatlng = new google.maps.LatLng(-25.363882,131.044922); 

var myOptions = {
zoom:8,
center:myLatlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};

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

var marker = new MarkerWithLabel({
position:myLatlng,$ b $ map:map,
draggable:true,
raiseOnDrag:true,
labelContent:A,
labelAnchor:新的google.maps.Point(3,30),
labelClass:labels,//标签的CSS类
labelInBackground:false
});

关于标记的基本知识可以在这里找到: https://developers.google.com/maps/documentation/javascript/overlays#Markers


How can I add label to my marker if my markers are populated on ajax success each result.

map.gmap('addMarker', { 'position': new google.maps.LatLng(result.latitude, result.longitude) });

I tried like this, but with no success:

map.gmap('addMarker', { 
    'position': new google.maps.LatLng(result.latitude, result.longitude), 
    'bounds': true,
    'icon': markerIcon,
    'labelContent': 'A',
    'labelAnchor': new google.maps.Point(result.latitude, result.longitude),
    'labelClass': 'labels', // the CSS class for the label
    'labelInBackground': false
});

解决方案

I doubt the standard library supports this.

But you can use the google maps utility library:

http://code.google.com/p/google-maps-utility-library-v3/wiki/Libraries#MarkerWithLabel

var myLatlng = new google.maps.LatLng(-25.363882,131.044922);

var myOptions = {
    zoom: 8,
    center: myLatlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

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

var marker = new MarkerWithLabel({
   position: myLatlng,
   map: map,
   draggable: true,
   raiseOnDrag: true,
   labelContent: "A",
   labelAnchor: new google.maps.Point(3, 30),
   labelClass: "labels", // the CSS class for the label
   labelInBackground: false
 });

The basics about marker can be found here: https://developers.google.com/maps/documentation/javascript/overlays#Markers

这篇关于带有标签的Google地图V3标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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