i'm facing a problem with the leaflet map
. they are
i'm unable to zoom
15km
radius
(frommarker
) while moving markeri'm unable to draw a line while moving (not a priority one)
here i what i have tried
Please refer jsfiddle as snippet is not working
jsfiddle: http://jsfiddle.net/eabangalore/x4gokvoa/8/
// Create the map
var map = L.map('map').setView([-31.4, -64.183], 12);
// Set up the OSM layer
L.tileLayer(
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18
}).addTo(map);
// add a marker in the given location
var lat = -31.4;
var lng = -64.183;
var marker = L.marker([lat, lng]).addTo(map);
// add a layer and add points
var myLayer = L.geoJson().addTo(map);
// geojsonFeature
var geojsonFeature = {
"type": "Feature",
"properties": {
"name": "Coors Field",
"amenity": "Baseball Stadium",
"popupContent": "This is where the Rockies play!"
},
"geometry": {
"type": "Point",
"coordinates": [-104.99404, 39.75621]
}
};
// put the marker
setTimeout(function () {
myLayer.addData(geojsonFeature);
}, 1000);
// update the marker
setTimeout(function () {
// clear layer
myLayer.clearLayers(); // inherited from LayerGroup
//myLayer.addData(geojsonFeature);
}, 3000);
// put the marker
setTimeout(function () {
myLayer.addData(geojsonFeature);
}, 5000);
// just fooling around
setInterval(function () {
lat = lat + ((Math.random() * 1) - 0.25) * 0.001;
lng = lng + ((Math.random() * 1) - 0.5) * 0.001;
marker.setLatLng([lat, lng]).update();
}, 200);
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<link href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" rel="stylesheet"/>
<div id="map"></div>
please help me thanks in advance!!!!!