admin管理员组文章数量:1278720
Is it possible to use the default blue dot marker in Google Maps in your own map (web)?
Long shot: I use ionic/cordova, so I pile the web Google Maps to iOS. Is it also possible to make the marker dynamic and show on the marker the direction the phone is pointing, as in Google Maps?
Thanks
Is it possible to use the default blue dot marker in Google Maps in your own map (web)?
Long shot: I use ionic/cordova, so I pile the web Google Maps to iOS. Is it also possible to make the marker dynamic and show on the marker the direction the phone is pointing, as in Google Maps?
Thanks
Share Improve this question asked Feb 14, 2017 at 10:04 huadevhuadev 4434 silver badges15 bronze badges3 Answers
Reset to default 9I had success using this:
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',
},
});
All this does is it places a marker as a blue dot, but further functionality is possible.
Is it possible to use the default blue dot marker in Google Maps in your own map (web)?
What do you mean, can't you just use an icon of a blue dot? Or are you after some of the functionality google has put into it when the blue dot appears in google maps (Always follows roads, moves smoothly etc). Because I think this unavailable via google's API's.
why you using V3 javascript, Google map V2 native is better and faster in the device. if you need this map javascript for some reason, the only possibility is getting the current location with geolocation.getCurrentPosition and make in the interval. The code is something like this:
// 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();
本文标签: javascriptGoogle maps v3 default (dynamic) blue dot as markerStack Overflow
版权声明:本文标题:javascript - Google maps v3 default (dynamic) blue dot as marker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741295465a2370792.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论