geojson as overlay

Want to post something that doesn't quite fit into the other forums? This is the place for that.
Post Reply
UA4WIY
Posts: 55
Joined: Mon Aug 29, 2016 7:41 pm

geojson as overlay

Post by UA4WIY » Fri Dec 09, 2016 6:07 am

Please specify how to use a geojson (http://en.wikipedia.org/wiki/GeoJSON) , which as an overlay in the VRS?

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            bootStrap.hookInitialised(function(pageSettings) {
                if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {

		var map;
		function initMap() {
		map = new google.maps.Map(document.getElementById('map'), {
 		 });

		  // NOTE: This uses cross-domain XHR, and may not work on older browsers.
		  map.data.loadGeoJson('https://storage.googleapis.com/maps-devrel/google.json');
				}
                }
            });
        });
    }
</script>
Not work

agw
Posts: 2241
Joined: Fri Feb 17, 2012 3:20 am

Re: geojson as overlay

Post by agw » Thu Dec 22, 2016 1:07 am

I haven't tried the script but if you want to add things to the map then you just need to call getNative to get the Google Maps map handle:

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            bootStrap.hookInitialised(function(pageSettings) {
                if(pageSettings.mapPlugin && pageSettings.mapPlugin.getNativeType() === 'GoogleMaps') {
                    var map = pageSettings.mapPlugin.getNative();
                    map.data.loadGeoJson('https://storage.googleapis.com/maps-devrel/google.json');
                }
            });
        });
    }
</script>


UA4WIY
Posts: 55
Joined: Mon Aug 29, 2016 7:41 pm

Re: geojson as overlay

Post by UA4WIY » Sat Dec 24, 2016 5:28 pm

Thank you for the way how to do what I wanted.
It is true in my case, this option n does not work, because my data file is too large and loadGeoJson can not handle this amount of data. We must look for other ways of drawing geoeson.

Post Reply