谷歌地图v3默认(动态)蓝点作为标记

6

在自己的地图(Web)中使用Google Maps默认的蓝色点标记是否可行?

可能性不大:我使用ionic / cordova,因此将Web Google Maps编译到iOS。是否还可以使标记动态,并在标记上显示电话指向的方向,就像在Google Maps中一样?

谢谢

3个回答

8

我成功地使用了这个:

var map = new google.maps.Map(document.getElementById('map');
var latLng = {"lat": 42.819213, "lng": -83.11099150000001};
var marker = new google.maps.Marker({
  position: latLng,
  map: map,
  icon: {
    path: google.maps.SymbolPath.CIRCLE,
    scale: 10,
    fillOpacity: 1,
    strokeWeight: 2,
    fillColor: '#5384ED',
    strokeColor: '#ffffff',
  },
});

这只是将标记设置为蓝点,但 更多功能可用

输入图像描述


1

在自己的网站上使用Google Maps中的默认蓝点标记是否可行?

你是说不能只使用一个蓝点图标吗?或者你想要一些谷歌地图中蓝点出现时具有的功能(始终跟随道路,平滑移动等)。因为我认为这些功能在谷歌的API中不可用。


我的意思是谷歌使用的蓝点及其方向和准确性功能,是的。恐怕它目前不可用。 - huadev

-1

为什么你使用 V3 JavaScript,Google Map V2 原生在设备中更好更快。 如果你因为某种原因需要使用此地图 JavaScript, 唯一的可能性是通过 geolocation.getCurrentPosition 获取当前位置并在一定时间间隔内进行更新。 代码类似于以下内容:

// Initialize the Google Maps API v3
var map = new google.maps.Map(document.getElementById('map'), {
  zoom: 15,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});

var marker = null;

function autoUpdate() {
  navigator.geolocation.getCurrentPosition(function(position) {  
    var newPoint = new google.maps.LatLng(position.coords.latitude, 
                                          position.coords.longitude);

    if (marker) {
      // Marker already created - Move it
      marker.setPosition(newPoint);
    }
    else {
      // Marker does not exist - Create it
      marker = new google.maps.Marker({
        position: newPoint,
        map: map
      });
    }

    // Center the map on the new position
    map.setCenter(newPoint);
  }); 

  // Call the autoUpdate() function every 5 seconds
  setTimeout(autoUpdate, 5000);
}

autoUpdate();

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接