简体   繁体   English

如何在gmaps.js上添加标记图像图标

[英]How can i add a marker image icon on gmaps.js

I am using GMaps.js for a WordPress page. 我正在将GMaps.js用于WordPress页面。 But I want to change the marker icon there. 但我想在那里更改标记图标。 They told to use $('<img/>').attr('src', url) .appendTo('#map'); 他们告诉使用$('<img/>').attr('src', url) .appendTo('#map');

My current Code ` 我当前的代码

var map;

$(document).ready(function(){
  map = new GMaps({
    el: '#map',
    lat: -12.043333,
    lng: -77.028333
  });

  map.addMarker({
    lat: -12.042,
    lng: -77.028333,
    title: 'Marker with InfoWindow',
    infoWindow: {
      content: '<p>HTML Content</p>'
    }
  });
});

Now how can I include a PNG icon as marker image there? 现在如何在其中包含PNG图标作为标记图像?

Go here: http://hpneo.github.io/gmaps/documentation.html#GMaps-addMarkers , search 'createMarker'. 转到此处: http : //hpneo.github.io/gmaps/documentation.html#GMaps-addMarkers ,搜索“ createMarker”。

Here it says that createMarkers accepts any options from google.maps.markerOptions. 此处表示createMarkers接受google.maps.markerOptions中的所有选项。 Follow this link: google.maps.markerOptions 跟随此链接: google.maps.markerOptions

It says 'icon' in the list. 它在列表中显示“ icon”。 So add an icon property with the url to your image. 因此,将带有url的icon属性添加到您的图像。

Right below createMarker is addMarker. 在createMarker的正下方是addMarker。 It accepts the same parameters as createMarker. 它接受与createMarker相同的参数。

This should get you going in the right direction. 这应该使您朝正确的方向前进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM