本文共 2041 字,大约阅读时间需要 6 分钟。
Openlayers ?????????? GISWeb????????????????????????? Leaflet?Cesium ????Openlayers ??????????????????????????????????
?????
?????
? Openlayers ????????Geolocation?API??????????????????????????
if (navigator.geolocation) { navigator.geolocation.watchPosition(function(position) { var coordinate = ol.proj.transform([ position.coords.longitude, position.coords.latitude ], 'EPSG:4326', 'EPSG:3857'); if (marker) { marker.setPosition(coordinate); } else { marker = new ol.Feature({ geometry: new ol.geom.Point(coordinate) }); vectorSource.addFeature(marker); } }, function(error) { console.error('Error getting geolocation:', error.message); });} ????????????????
? Openlayers ???????????? LineString ???????????????????
var trackLineString = new ol.geom.LineString([]);trackLineString.appendCoordinate(coordinate);var trackFeature = new ol.Feature({ geometry: trackLineString});var vectorSource = new ol.source.Vector({ features: [trackFeature]});var vectorLayer = new ol.layer.Vector({ source: vectorSource});map.addLayer(vectorLayer); ????????????????
appendCoordinate ???????????????vectorLayer ? vectorSource ?????????????????????????????????? Openlayers ? GIS ??????????????????????????????
转载地址:http://gkpfk.baihongyu.com/