how to show some markers on a static image using openlayers 3 -


i trying show marker on static image ie

given static image of size in feet , set of point in feets how mark image or marker on static image using openlayers3

i understand have provision in openlayer3 use static image base layer of map

i not getting how show marker on static image(base layer)for given plots on image

any more thank please suggest war it

i show static image map shown below

<!doctype html> <html> <head>     <title>static image example</title>     <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.css" type="text/css">     <script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.js"></script>  </head> <body> <div class="container-fluid">      <div class="row-fluid">         <div class="span12">             <div id="map" class="map"></div>         </div>     </div>  </div> <script>     // map views need projection.  here want map image     // coordinates directly map coordinates, create projection uses     // image extent in pixels.     var extent = [0, 0, 1024, 968];     var projection = new ol.proj.projection({         code: 'xkcd-image',         units: 'pixels',         extent: extent     });      var map = new ol.map({         layers: [             new ol.layer.image({                 source: new ol.source.imagestatic({                     attributions: [                         new ol.attribution({                             html: '&copy; <a href="http://xkcd.com/license.html">xkcd</a>'                         })                     ],                     url: 'colorful-triangles-background.jpg',                     projection: projection,                     imageextent: extent                 })             })         ],         target: 'map',         view: new ol.view({             projection: projection,             center: ol.extent.getcenter(extent),             zoom: 2         })     });  </script> </body> </html> 

but have no idea how plot markers plots json given plot thing below

[{ x:1.234, y:3.34, units:feet }, { x:2.234, y:4.34, units:feet }, { x:7.234, y:9.34, units:feet }]

  • create icon style
  • create icon feature
  • setup new vector layer vector source
  • add vector layer in map's layer
  • i have displayed marker on click of map @ mouse position, can add markers on event want
  • also since did not have images referring have referred open layer examples image.

    <!doctype html> <html> <head>     <title>static image example</title>     <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com   /bootstrap/3.3.4/css/bootstrap.min.css">     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>     <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.css" type="text/css">     <script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.js">    </script>  </head> <body> <div class="container-fluid">  <div class="row-fluid"> <div class="span12">     <div id="map" class="map"></div> </div> </div> </div> <script>     // map views need projection.  here want map     image     // coordinates directly map coordinates, create projection uses     // image extent in pixels.     var extent = [0, 0, 1024, 968];     var projection = new ol.proj.projection({         code: 'xkcd-image',         units: 'pixels',         extent: extent     });   var iconstyle = new ol.style.style({     image: new ol.style.icon(({         anchor: [15, 24],         size: [32, 48],         anchorxunits: 'pixels',         anchoryunits: 'pixels',         opacity: 0.75,         src: 'http://www2.psd100.com/ppp/2013/11/0501/map-marker-icon-1105213652.png'     })) });   //create feature  var iconfeature = new ol.feature({         geometry: new ol.geom.point([72.5800, 23.0300])      });  //setup vector source var vectorsource = new ol.source.vector({     features: [iconfeature] });  //setup vector layer var vectorlayer = new ol.layer.vector({     source: vectorsource });  iconfeature.setstyle(iconstyle);   var map = new ol.map({ layers: [     new ol.layer.image({         source: new ol.source.imagestatic({             attributions: [                 new ol.attribution({                     html: '&copy; <a href="http://xkcd.com/license.html">xkcd</a>'                 })             ],             url: 'http://imgs.xkcd.com/comics/online_communities.png',             projection: projection,             imageextent: extent         })     }), vectorlayer //add vector in layers ], target: 'map', view: new ol.view({     projection: projection,     center: ol.extent.getcenter(extent),     zoom: 2 }) });  //on map click setup marker  map.on('click', function (evt) {      var feature = new ol.feature(new ol.geom.point(evt.coordinate));     feature.setstyle(iconstyle);     vectorsource.clear();     vectorsource.addfeature(feature);     selectedlong = evt.coordinate[0];     selectedlat = evt.coordinate[1];  });  </script> </body> </html> 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -