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 badges
Add a ment  | 

3 Answers 3

Reset to default 9

I 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