Geolocation Marker for Google Maps v3

Geolocation Marker for Google Maps v3

This library uses geolocation to add a marker and accuracy circle to a map. The marker position is automatically updated as the user position changes.

To add the Geolocation Marker, just instantiate a new GeolocationMarker object, passing your map to it:

var mapOptions = {
  zoom: 17,
  center: new google.maps.LatLng(-34.397, 150.644),
  mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map_canvas'),
  mapOptions);
var GeoMarker = new GeolocationMarker(map);

See the example.

Note: This library will only function in browsers supporting the W3C Geolocation API. This excludes Internet Explorer versions 8 and older.

class GeolocationMarker

This class extends google.maps.MVCObject.

Constructor

ConstructorDescription
GeolocationMarker(map?:google.maps.Map, marker_opts?:google.maps.MarkerOptions, circle_opts?:google.maps.CircleOptions)A marker and accuracy circle positioned on the map to track the user's location.

Methods

MethodsReturn ValueDescription
getAccuracy()number|nullReturns the current accuracy of the location data. Will return null if a position has not yet been obtained.
getBounds()google.maps.LatLngBounds|nullReturns the lat/lng bounds containing the marker and accuracy circle. Will return null if a position has not yet been obtained.
getMap()google.maps.Map 
getMinimumAccuracy()number|nullReturns the minimum accuracy (in meters) that must be achieved before the marker is initially drawn on the map. Returns null if no minimum is specified.
getPosition()google.maps.LatLng|nullReturns the center of the marker and accuracy circle. Will return null if a position has not yet been obtained.
getPositionOptions()PositionOptionsInterfaceReturns the current options used to call the geolocation.watchPosition method.
setCircleOptions(options:google.maps.CircleOptions) This method will ignore certain properties of the google.maps.CircleOptions object. It will ignore position, radius and map properties as these are set by the library.
setMap(map:google.maps.Map)  
setMarkerOptions(options:google.maps.MarkerOptions) This method will ignore certain properties of the google.maps.MarkerOptions object. It will ignore position and map properties as these are set by the library.
setMinimumAccuracy(accuracy:number|null) Sets the minimum accuracy (in meters) that must be achieved before the marker is initially drawn on the map.
setPositionOptions(positionOpts: PositionOptionsInterface) Sets the options used to call the geolocation.watchPosition method.

Events

EventsArgumentsDescription
accuracy_changed  
geolocation_errorPositionErrorInterfaceTriggered whenever geolocation fails. Can be caused by a user denying permission to access location data.
position_changed
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值