javascript - Open Maps draggable circle with adjustable radius -


i used use google maps library has given me csp 'unsafe-eval' errors. want remain secure i'm starting @ open maps.

here's screencast of functionality want port on open maps - http://screencast.com/t/5f5leaesrr. on map click want circle draggable adjustable radius. using leaflet able circle show on map isn't draggable , radius can't adjusted dragging shown in gmaps screencast. appreciated.

figured out using leaflet , circle editor plugin

here's small example using dependencies https://github.com/kartena/leaflet.editablehandlers

<!doctype html> <html> <head>     <title>maps</title>     <style type="text/css">         #map { width: 481px;height: 300px; }     </style>      <script type="text/javascript" src="http://code.jquery.com/jquery-2.0.3.js"></script>      <!-- plugin dependecies -->     <link rel="stylesheet" href="../lib/leaflet-0.6.4/leaflet.css" />     <link rel="stylesheet" href="../css/marker-extend.css" />      <script src="../lib/leaflet-0.6.4/leaflet-src.js"></script>     <script src="../src/l.circleeditor.js" ></script>     <!-- end plugin dependecies -->  </head> <body>     <div id="map" style="width: 600px; height: 400px"></div>     <br>     <input id="lat" placeholder="lat" type="number"/>     <input id="lng" placeholder="lng" type="number"/>     <input id="radius" placeholder="radius" type="number"/>      <script>          var map = l.map('map').setview([40, -98.50], 4);          l.tilelayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {             maxzoom: 18,             attribution: 'map data &copy; <a href="http://openstreetmap.org">openstreetmap</a> contributors, ' +                 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">cc-by-sa</a>, ' +                 'imagery © <a href="http://mapbox.com">mapbox</a>',             id: 'examples.map-i875mjb7'         }).addto(map);             var updatevalues = function(circle) {             console.log(circle._latlng.lat, circle._latlng.lng ,circle._mradius);             $('#lat').val(circle._latlng.lat);             $('#lng').val(circle._latlng.lng);             $('#radius').val(circle._mradius);          }          // set 1 circle         var circleset = false;          var onmapclick = function(e) {             if (!circleset) {                 var circlelocation = new l.latlng(e.latlng.lat, e.latlng.lng),                 circleoptions = {                     color: '#0159e5',                      fillcolor: '#a8c5e4',                      fillopacity: 0.7,                     extendediconclass : 'extend-icon'                 };                  var circle = new l.circleeditor(circlelocation, 786500, circleoptions);                 map.addlayer(circle);                 circleset = true;                 updatevalues(circle);                 circle.on('edit', function(){                     updatevalues(this);                 });             }         }          map.on('click', onmapclick);      </script>      <!-- https://github.com/kartena/leaflet.editablehandlers --> </body> </html> 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -