fb_pixel

How to use Openlayers to set information about objects on the map?

Development | Programming languages
Description
Recently, I just plunged into this environment and have a difficult time understanding it myself.I have a task to deal with openlayers.First you need to create a small program that displays a small street and when you click on the building to display any information.

Everything I have done so far is displayed below.
<! DOCTYPE html>
<html>
  <head>
    <title>GeoJSON</title>
    <link rel="stylesheet" href="ol.css" type="text/css">
    <script src="ol.js"></script>
  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      var image=new ol.style.Circle({
        radius: 5,
        fill: null
        stroke: new ol.style.Stroke({color:'red', width: 1})
      });

      var styles={
        'Point': new ol.style.Style({
          image: image
        })
        'LineString': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color:'#ffffff',
            width: 1
          })
        })
		
		//Line Style
        'MultiLineString': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color:'#000000',
            width: 1
          })
        })
        
		
		//Polygon Style
        'MultiPolygon': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color:'#000000',
            width: 1
          })
          fill: new ol.style.Fill({
            color:'rgba(255, 255, 0, 0.9)'
          })
        })
        
       
        'Circle': new ol.style.Style({
          stroke: new ol.style.Stroke({
            color:'red',
            width: 2
          })
          fill: new ol.style.Fill({
            color:'rgba(255,0,0,0.2)'
          })
        })
      };

      var styleFunction=function(feature) {
        return styles[feature.getGeometry().getType()];
      };

	//Description of the coordinate system and objects
      var geojsonObject={
		//Description of the coordinate system
        'type':'FeatureCollection',
        'crs': {
          'type':'name',
          'properties': {
            'name':'EPSG: 3857'
          }
        },
        'features':[{
          'type':'Feature',
          'geometry': {
            'type':'MultiLineString',
            'coordinates':[
              [[-15e5, 3e5],[6e5, 3e5]],
			[[-15e5, 5e5],[6e5, 5e5]],
			
			[[-14e5, 4e5],[-12e5, 4e5]],[[- 11e5, 4e5],[-9e5, 4e5]],[[- 8e5, 4e5],[ -6e5, 4e5]],[[- 5e5, 4e5],[-3e5, 4e5]],[[- 2e5, 4e5],[-0e5, 4e5]],[[[1e5, 4e5],[3e5, 4e5 ]],[[4e5, 4e5],[5e5, 4e5]],
            ]
          }
        }, {
          'type':'Feature',
          'geometry': {
            'type':'MultiPolygon',
            'coordinates':[
              
			[[[-5e5, 6e5],[-5e5, 8e5],[-9e5, 8e5],[-9e5, 6e5]]],
			[[[-10e5, 6e5],[-10e5, 8e5],[-14e5, 8e5],[-14e5, 6e5]]],
			[[[-4e5, 6e5],[-4e5, 8e5],[-0e5, 8e5],[-0e5, 6e5]]],
			[[[1e5, 6e5],[1e5, 8e5],[5e5, 8e5],[5e5, 6e5]],
			
			
			
			
              [[[3e5, -1e5],[3e5, -2.5e5],[1e5, -2.5e5],[1e5, -1e5]]],
			[[[1e5, 0e5],[1e5, 2e5],[5e5, 2e5],[5e5, -3e5],[3.5e5, -3e5],[3.5e5.0e5] ]],
			[[[0e5, 1e5],[0e5, -3e5],[- 14e5, -3e5],[- 14e5.1e5],[- 11e5.1e5],[- 11e5, 2e5],[- 3e5,2e5],[- 3e5,1e5]],
			
            ]
          }
        }]
      };
	
	
	//GeoJSON Library Connection Announcement
      var vectorSource=new ol.source.Vector({
        features:(new ol.format.GeoJSON()).readFeatures(geojsonObject)
      });
	
	
	//Collect it all in 1 layer.
      var vectorLayer=new ol.layer.Vector({
        source: vectorSource,
        style: styleFunction
      });
	
	//Creating an object -"Map"
      var map=new ol.Map({
        layers:[
          vectorLayer
        ],
        target:'map',
		//Add user interface
        controls: ol.control.defaults({
          attributionOptions:({
            collapsible: false
          })
        })
		
		//Camera position when loading
        view: new ol.View({
          center:[-4e5, 2e5],
          zoom: 6
        })
      });
    </script>
  </body>
</html>
Attachments
No attachments
Info
Description
Ask this question better.. 

on January 13th, 2020 (10:12 pm)
Description
Ok, I know where the error is.
on March 18th, 2020 (2:57 pm)
All coments
This job has not been commented yet.