簡體   English   中英

如何在gmaps.js上添加標記圖像圖標

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

我正在將GMaps.js用於WordPress頁面。 但我想在那里更改標記圖標。 他們告訴使用$('<img/>').attr('src', url) .appendTo('#map');

我當前的代碼

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>'
    }
  });
});

現在如何在其中包含PNG圖標作為標記圖像?

轉到此處: http : //hpneo.github.io/gmaps/documentation.html#GMaps-addMarkers ,搜索“ createMarker”。

此處表示createMarkers接受google.maps.markerOptions中的所有選項。 跟隨此鏈接: google.maps.markerOptions

它在列表中顯示“ icon”。 因此,將帶有url的icon屬性添加到您的圖像。

在createMarker的正下方是addMarker。 它接受與createMarker相同的參數。

這應該使您朝正確的方向前進。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM