My goal is to add a WMS layer to an existing google map with selectable (toggleable) layers. Here is my working code (with the exception of valid KML URLs):
html { height: 100%; }body { height: 100%; margin: 0; padding: 0; }#map_canvas { height: 100%; }#checkboxes {position: absolute;top: 30px;right: 10px;font-family: 'arial', 'sans-serif';font-size: 14px;background-color: white;border: 1px solid gray;padding: 5px 10px;}
var map;var layers = []; function initialize() {var myLatLng = new google.maps.LatLng(18.485,105.049);var myOptions = { zoom: 6, center: myLatLng, mapTypeId: google.maps.MapTypeId.HYBRID}map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);layers [0] = new google.maps.KmlLayer('some_link.kml',{preserveViewport: false, suppressInfoWindows: false});layers [1] = new google.maps.KmlLayer('another_link.kml',{preserveViewport: false, suppressInfoWindows: false});layers [2] = new google.maps.KmlLayer('one_more_link.kml',{preserveViewport: false, suppressInfoWindows: false});for (var i = 0; i < layers.length; i++) { layers.setMap(null); }}function toggleLayer(i) {if (layers.getMap() === null) {layers.setMap(map);}else {layers.setMap(null);} }
Layer 1
Layer 2
Layer 3
I want to add the following WMS layer to the map: http://192.170.232.61:8080/geoserve...ARK:false;KMSCORE:40;MODE:refresh;KMATTR:true
The WMS url has the required parameters embedded in the string. Following the link shows the correct PNG image I wish to overlay.
I've tried modeling my code after various examples found here and on other forums as well as inspecting the source code using developer tools for similar examples. I've had no success thus far. I'm fairly new to javascript, but come from a fairly strong GIS background. Any help is most appreciated!
أكثر...
html { height: 100%; }body { height: 100%; margin: 0; padding: 0; }#map_canvas { height: 100%; }#checkboxes {position: absolute;top: 30px;right: 10px;font-family: 'arial', 'sans-serif';font-size: 14px;background-color: white;border: 1px solid gray;padding: 5px 10px;}
var map;var layers = []; function initialize() {var myLatLng = new google.maps.LatLng(18.485,105.049);var myOptions = { zoom: 6, center: myLatLng, mapTypeId: google.maps.MapTypeId.HYBRID}map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);layers [0] = new google.maps.KmlLayer('some_link.kml',{preserveViewport: false, suppressInfoWindows: false});layers [1] = new google.maps.KmlLayer('another_link.kml',{preserveViewport: false, suppressInfoWindows: false});layers [2] = new google.maps.KmlLayer('one_more_link.kml',{preserveViewport: false, suppressInfoWindows: false});for (var i = 0; i < layers.length; i++) { layers.setMap(null); }}function toggleLayer(i) {if (layers.getMap() === null) {layers.setMap(map);}else {layers.setMap(null);} }
Layer 1
Layer 2
Layer 3
I want to add the following WMS layer to the map: http://192.170.232.61:8080/geoserve...ARK:false;KMSCORE:40;MODE:refresh;KMATTR:true
The WMS url has the required parameters embedded in the string. Following the link shows the correct PNG image I wish to overlay.
I've tried modeling my code after various examples found here and on other forums as well as inspecting the source code using developer tools for similar examples. I've had no success thus far. I'm fairly new to javascript, but come from a fairly strong GIS background. Any help is most appreciated!
أكثر...