gis map rendering using Openlayer 6

288 Views Asked by At

We are using Mapnik, Mapproxy and Openlyer6 for the development of GIS based web solutions. The GIS data from Postgis enabled postgresql DB. We are using EPSG: 32643 Projection and got the Map output but when we tried to add a point on the map that is not displaying. The code is posted here... I have added 2 points inside the map area but nothing displayed.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
    <link rel="stylesheet" href="https://openlayers.org/en/v6.4.3/css/ol.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
    <script src="https://openlayers.org/en/v6.4.3/build/ol.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.6.1/proj4.js"></script>
    <style>
      html, body, .map {
        margin: 0;
        padding: 0;
        width: 99%;
        height: 99%;
    border:1px solid #ccc;
      }
    </style>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script>

proj4.defs("EPSG:32643","+proj=utm +zone=43 +datum=WGS84 +units=m +no_defs");
ol.proj.proj4.register(proj4);

const iconFeature = new ol.Feature({
  geometry: new ol.geom.Point(ol.proj.fromLonLat([614971.473,1218630.894])),


  projection: "EPSG:32643",
  name: 'Somewhere near Nottingham',
});

 
 

var map = new ol.Map({
  target: 'map',
  layers: [    
    new ol.layer.Tile({
            source: new ol.source.XYZ({
           url: "http://192.168.3.32:8081/tms/1.0.0/district/distgrid" + "/{z}/{x}/{-y}.png",
           projection: "EPSG:32643",
          }),
          }),
    new ol.layer.Tile({
            source: new ol.source.XYZ({
           url: "http://192.168.3.32:8081/tms/1.0.0/road/roadgrid" + "/{z}/{x}/{-y}.png" ,
        projection: "EPSG:32643",
          }),
          }),
    new ol.layer.Tile({
            source: new ol.source.XYZ({
           url: "http://192.168.3.32:8081/tms/1.0.0/Landmark/landmarkgrid" + "/{z}/{x}/{-y}.png" ,
        projection: "EPSG:32643",
          }),
          }),
    new ol.layer.Vector({
      source: new ol.source.Vector({    
        features: [iconFeature],
    projection: "EPSG:32643",
 }),
  renderBuffer: 200,
  style: new ol.style.Style({
        image: new ol.style.Icon({
          anchor: [0.5, 46],
          anchorXUnits: 'fraction',
          anchorYUnits: 'pixels',
          src: 'https://openlayers.org/en/latest/examples/data/icon.png'
        })
      })

      }),  
  ],
  view: new ol.View({
    projection: "EPSG:32643",
    units:"m",
    //extent: [485266.3703,917118.208000001,764929.9067,1414398.9922],
    zoom:1,
    maxZoom:15,
    minZoom:1,
    center:[0,0],
 

  })
});

 
var layer = new ol.layer.Vector({
     source: new ol.source.Vector({
         features: [
             new ol.Feature({
        geometry: new ol.geom.Point(ol.proj.fromLonLat([584658.379776645,1246789.46624421])),
        projection: "EPSG:32643",
             })
         ]
     })
 });
map.addLayer(layer);
map.getView().setZoom(map.getView().getZoom() - 6);

    </script>
  </body>
</html>

need to know whether the code is correct or not.

enter image description here

0

There are 0 best solutions below