Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <div id="mapdiv"></div>
- <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
- <script>
- map = new OpenLayers.Map("mapdiv");
- map.addLayer(new OpenLayers.Layer.OSM());
- let zoom=16;
- let size = new OpenLayers.Size(21,25);
- let offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
- let lonLat = new OpenLayers.LonLat( -81.7692887,26.1741378 ).transform(
- new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
- map.getProjectionObject() // to Spherical Mercator Projection
- );
- map.setCenter (lonLat, zoom);
- let markers = new OpenLayers.Layer.Markers( "Markers" );
- map.addLayer(markers);
- let marker_icon='https://p1.hiclipart.com/preview/365/352/961/simple-linux-logo-black-and-white-penguin-png-clipart.jpg';
- let marker_icon2='https://p7.hiclipart.com/preview/368/650/539/tuxedo-linux-computer-icons-linux.jpg';
- let marker_list=[
- [-81.7680000,26.1741378,marker_icon],
- [-81.7640001,26.1741470],
- [-81.7780000,26.1741378,marker_icon2],
- [-81.7640001,26.1721470]
- ];
- for(m of marker_list){
- addMarker(m[0],m[1],m[2]);
- }
- function addMarker(lon,lat,icon_url){
- let cor = new OpenLayers.LonLat(lon, lat).transform(
- new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
- map.getProjectionObject() // to Spherical Mercator Projection
- );
- if(icon_url !== undefined){
- var icon = new OpenLayers.Icon(icon_url,size,offset);
- }
- markers.addMarker(new OpenLayers.Marker(cor,icon));
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment