how to make a center of map

المشرف العام

Administrator
طاقم الإدارة
I want to make a viewed of map with zoom=16. and the center is my location (geolocation)this is my javascript.

var view = new ol.View({ center:eek:l.proj.transform([110.365,-7.795],'EPSG:4326','EPSG:900913'), zoom:12.2 }); var map = new ol.Map({ target:'map', renderer:'canvas', view: view});var newLayer = new ol.layer.Tile({ source : new ol.source.OSM()});map.addLayer(newLayer);$(document).ready(function(){var geolocation = new ol.Geolocation({ projection: view.getProjection() });function el(id) {return document.getElementById(id);}el('track').addEventListener('change', function() {geolocation.setTracking(this.checked);}); var accuracyFeature = new ol.Feature(); geolocation.on('change:accuracyGeometry', function() { accuracyFeature.setGeometry(geolocation.getAccuracyGeometry()); }); var positionFeature = new ol.Feature(); positionFeature.setStyle(new ol.style.Style({ image: new ol.style.Circle({ radius: 6, fill: new ol.style.Fill({ color: '#3399CC' }), stroke: new ol.style.Stroke({ color: '#fff', width: 2 }) }) })); geolocation.on('change:position', function() { var coordinates = geolocation.getPosition(); positionFeature.setGeometry(coordinates ? new ol.geom.Point(coordinates) : null); }); geolocation.on('change', function(evt) { console.log(geolocation.getPosition()); map.getView().setCenter(geolocation.getPosition()); }); var featuresOverlay = new ol.FeatureOverlay({ map: map, features: [accuracyFeature, positionFeature] });}

أكثر...
 
أعلى