var QWMSURL = 'http://wms.mapexchange.co.za/' + 'QWMS.aspx'; var TileCacheURL = 'http://m1.mapexchange.co.za/tilecache.py?,http://m2.mapexchange.co.za/tilecache.py?,http://m3.mapexchange.co.za/tilecache.py?,http://m4.mapexchange.co.za/tilecache.py?' var TileCacheURL2 = 'http://m1.mapexchange.co.za/Cache/,http://m2.mapexchange.co.za/Cache/,http://m3.mapexchange.co.za/Cache/,http://m4.mapexchange.co.za/Cache/' //Include the OpenLayers js file //'http://wms.mapexchange.co.za/OpenLayers.js'; var OLjs = 'http://wms.mapexchange.co.za/' + 'HttpCombiner.ashx?s=OLPath&t=text/javascript&v=1'; var gzip_JScript = 'http://wms.mapexchange.co.za/' + 'HttpCombiner.ashx?s=gzip_JScript&t=text/javascript&v=1'; document.write(""); document.write(""); //Global variables var mapObj,mapContainer,mapContentDiv,mapToolsDiv,mapCategorySel,mapPOISel,mapAirportSel,mapAirportSelDir,txtDirections,anchorLat,anchorPopup,curMousePos, anchorLon,anchorZoom,anchorDesc,anchorFeature,poiSel,routeLayer,SAMap,Topo,Hybrid,StreetMap,Labels,POI,selectControl,popUpInfo,Routing, showCategories,showAirports,showPOIs,defSelCategory,AdvertiserPlaces,clickControl,mapAirportRow,mapDirectionsRow,mapPOIRow,mapCategoryRow, mapPOIRadiusRow,mapPOIRadiusSel,isHereAboutSite,extSiteAddress,vecFeatureLayer,selectVecFeature,showAdvertiserPlaces; //Map Initialisation function initMap(mapContainerDiv, latitude, longitude, zoom, description, defCategory, showCategoryPicker, showAirportDir, showAdDir, showClickMapOnly, showMarker, showVecFeatureLayer, showAdvPlaces) { if (SAMap) { SAMap.destroy(); } if (Topo) { Topo.destroy(); } if (Hybrid) { Hybrid.destroy(); } if (StreetMap) { StreetMap.destroy(); } if (Labels) { Labels.destroy(); } //if (POI) { POI.destroy(); } if (Routing) {Routing.destroy(); } if (vecFeatureLayer) {vecFeatureLayer.destroy(); } if (mapObj) { if (mapObj.map) { mapObj.map.destroy(); } mapObj = null; } isHereAboutSite = false; extSiteAddress = window.location.href; if (extSiteAddress.match(/tagitbagit/gi) !== null) { if (extSiteAddress.match(/placesummary/gi) == null) { isHereAboutSite = true; } } OpenLayers.Control.Hover = OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: { 'delay': 500, 'pixelTolerance': null, 'stopMove': false }, initialize: function(options) { this.handlerOptions = OpenLayers.Util.extend( {}, this.defaultHandlerOptions ); OpenLayers.Control.prototype.initialize.apply( this, arguments ); this.handler = new OpenLayers.Handler.Hover( this, {'pause': this.onPause, 'move': this.onMove}, this.handlerOptions ); }, onPause: function(evt) { ShowPOIPopup(evt.xy); }, onMove: function(evt) { } }); OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: { 'single': true, 'double': false, 'pixelTolerance': 0, 'stopSingle': false, 'stopDouble': false }, initialize: function(options) { this.handlerOptions = OpenLayers.Util.extend( {}, this.defaultHandlerOptions ); OpenLayers.Control.prototype.initialize.apply( this, arguments ); this.handler = new OpenLayers.Handler.Click( this, { 'click': this.trigger }, this.handlerOptions ); }, trigger: function(e) { try { var lonlat = mapObj.map.getLonLatFromViewPortPx(e.xy); if (confirm("You clicked near " + lonlat.lat + " N, " + lonlat.lon + " E. Would you like to use this point?") == true) { if (anchorFeature) { anchorFeature.destroy(); } if (mapObj.markers) { mapObj.markers.clearMarkers(); } mapObj.addMarker(lonlat.lat, lonlat.lon, 'http://wms.mapexchange.co.za/img/marker.png', [21, 25], 1, '', true); JQ("input[id*='txtLatitude']").val(lonlat.lat); JQ("input[id*='txtLongitude']").val(lonlat.lon); if (typeof DrawGeoFenceCircle == 'function') { DrawGeoFenceCircle(); } } } catch(e) { } } }); defSelCategory = defCategory; showCategories = showCategoryPicker; showAirports = showAirportDir; showPOIs = showAdDir; showAdvertiserPlaces = showAdvPlaces; anchorLat = latitude; anchorLon = longitude; anchorZoom = zoom; anchorDesc = description; mapContainer = mapContainerDiv; mapContentDiv = mapContainerDiv + '_mapContent'; mapToolsDiv = mapContainerDiv + '_mapTools'; mapCategorySel = mapContainerDiv + '_mapCategory'; mapCategoryRow = mapContainerDiv + '_mapCategoryRow'; mapPOISel = mapContainerDiv + '_mapPOI'; mapPOIRow = mapContainerDiv + '_mapPOIRow'; mapPOIRdo = mapContainerDiv + '_mapPOIRdo'; mapAirportSel = mapContainerDiv + '_mapAirport'; mapAirportSelDir = mapContainerDiv + '_mapAirportSelDir'; mapAirportRow = mapContainerDiv + '_mapAirportRow'; mapAirportRdo = mapContainerDiv + '_mapAirportRdo'; txtDirections = mapContainerDiv + '_mapDirections'; mapDirectionsRow = mapContainerDiv + '_mapDirectionsRow'; mapPOIRadiusRow = mapContainerDiv + '_mapPOIRadiusRow'; mapPOIRadiusSel = mapContainerDiv + '_mapPOIRadiusSel'; var mapContentHeight = JQ('#' + mapContainerDiv).attr("offsetHeight"); var mapContentWidth = JQ('#' + mapContainerDiv).attr("offsetWidth"); JQ('#' + mapContainerDiv).html('
' + '


' + '
Filter by category:
' + '
' + '
' + '
Show POIs within:
' + '
' + '
' + '
Directions to POI:
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
'); //Set tile transparency OpenLayers.Util.onImageLoadErrorColor = "transparent"; //Image Reload attempts OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; var options; if (showAdvertiserPlaces !== false) { options = { resolutions:[0.045,0.02147705476784352,0.010250308477798894,0.00489214303477728,0.002334862753111908,0.0011143550049773855,0.00053184585494933,0.00025383294566216273,0.00012114631279709595,0.00005781924433034516,0.00002759526838040331],//0.0000131703353408725], 'projection':'EPSG:4148', maxExtent: new OpenLayers.Bounds(15,-35,33,-21), eventListeners: { "moveend": mapPanned, "zoomend" : mapZoomed }//, //'tileSize': new OpenLayers.Size(100,100) }; } else { options = { resolutions:[0.045,0.02147705476784352,0.010250308477798894,0.00489214303477728,0.002334862753111908,0.0011143550049773855,0.00053184585494933,0.00025383294566216273,0.00012114631279709595,0.00005781924433034516,0.00002759526838040331],//0.0000131703353408725], 'projection':'EPSG:4148', maxExtent: new OpenLayers.Bounds(15,-35,33,-21)//, //'tileSize': new OpenLayers.Size(100,100) }; } //maxResolution: "auto", //minResolution: 0.000003, //Map object mapObj = new Object(); //Map variables mapObj.lat = latitude; mapObj.lon = longitude; mapObj.zoom = zoom; mapObj.mapDiv = mapContentDiv; mapObj.layers = null; mapObj.markers = null; mapObj.feature = null; mapObj.popup = null; mapObj.Toolbar = null; mapObj.LayerSwitcher = null; mapObj.OverviewMap = null; mapObj.key = ''; mapObj.token = ''; var mapToolsHeight = 220; if (showCategoryPicker == false || showClickMapOnly == true) { JQ('#' + mapCategoryRow).css("display", "none"); mapToolsHeight = mapToolsHeight - 20; } if (showAirportDir == false || showClickMapOnly == true) { JQ('#' + mapAirportRow).css("display", "none"); mapToolsHeight = mapToolsHeight - 20; } if (showAdDir == false || showClickMapOnly == true) { JQ('#' + mapPOIRadiusRow).css("display", "none"); JQ('#' + mapPOIRow).css("display", "none"); mapToolsHeight = mapToolsHeight - 40; } if ((showAdDir == false && showAirportDir == false) || showClickMapOnly == true) { JQ('#' + mapDirectionsRow).css("display", "none"); if (showCategoryPicker == false) { mapToolsHeight = mapToolsHeight - 140; JQ('#' + mapToolsDiv).css('display','none'); } else { mapToolsHeight = mapToolsHeight - 110; } } JQ('#' + mapToolsDiv).css("height", mapToolsHeight + "px"); JQ('#' + mapContentDiv).css("height", (mapContentHeight - mapToolsHeight) + "px"); //Create the map instance mapObj.map = new OpenLayers.Map( (mapContentDiv) , options); //Add the mapping functions mapObj.addLayers = function(layers) { QMap_addLayers(mapObj,layers); } mapObj.zoomToPoint = function(lat,lon,zoom) { QMap_ZoomToPoint(mapObj,lat,lon,zoom); } mapObj.showToolbar = function(visible,toolbarDiv) { QMap_ShowToolbar(mapObj,visible,toolbarDiv); } mapObj.showLayerSwitcher = function(visible) { QMap_ShowLayerSwitcher(mapObj,visible); } mapObj.showOverviewMap = function(visible) { QMap_ShowOverviewMap(mapObj,visible); } mapObj.addMarker = function(lat,lon,icon,size,opacity,content,isAnchor) { QMap_AddMarker(mapObj,lat,lon,icon,size,opacity,content,isAnchor); } mapObj.addLayers('StreetMap'); if (showVecFeatureLayer == true) { var symbolizer = OpenLayers.Util.applyDefaults( {externalGraphic: "${featureImg}", fillOpacity: ".75", pointRadius: 12}, OpenLayers.Feature.Vector.style["default"]); var styleMap = new OpenLayers.StyleMap({"default": symbolizer, "select": {fillOpacity: "1"}, "hover": {fillOpacity: "1"}}); vecFeatureLayer = new OpenLayers.Layer.Vector("Features", {styleMap:styleMap}); } if (showPOIs !== false && showClickMapOnly !== true) { JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/RecordExtentImpression", data: {CategoryID:defCategory, Lat1:JSON.stringify(mapObj.map.getExtent().bottom), Lon1:JSON.stringify(mapObj.map.getExtent().left), Lat2:JSON.stringify(mapObj.map.getExtent().top), Lon2:JSON.stringify(mapObj.map.getExtent().right), IsHereAboutSite:isHereAboutSite, ExtSiteAddress:JSON.stringify(extSiteAddress), IPAddress:JSON.stringify('34.204.191.31')}, dataType: "jsonp", success: function(msg) { }, error: function(msg) { } }); } if (showCategories !== false && showClickMapOnly !== true) { JQ('#imgCategoryLoading').css('display','inline'); JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetCategories", data: {}, dataType: "jsonp", success: function(msg) { JQ('#imgCategoryLoading').css('display','none'); JQ('#' + mapCategorySel).html(msg.d); JQ('#' + mapCategorySel).val(defCategory); FilterMapPOI(defCategory); }, error: function(msg) { JQ('#imgCategoryLoading').css('display','none'); JQ('#' + mapCategorySel).html(''); } }); } else { if (showClickMapOnly !== true) { FilterMapPOI(defCategory); } } if (showAirports !== false && showClickMapOnly !== true) { LoadAirports(); } if (showMarker !== false) { mapObj.addMarker(latitude, longitude, 'http://wms.mapexchange.co.za/img/marker.png', [21, 25], 1, description, true); mapObj.markers.setZIndex(1000); } mapObj.showToolbar(false); mapObj.showLayerSwitcher(false); mapObj.showOverviewMap(false); if (selectControl) { selectControl.destroy(); } if (showClickMapOnly == true) { clickControl = new OpenLayers.Control.Click(); mapObj.map.addControl(clickControl); clickControl.activate(); } else { if (showAdvertiserPlaces !== false || showMarker !== false) { selectControl = new OpenLayers.Control.Hover({ handlerOptions: { 'delay': 1000, 'pixelTolerance': 6 } }); mapObj.map.addControl(selectControl); selectControl.activate(); } } return mapObj; } function ReInitMap(latitude, longitude, zoom, description, defCategory, showCategoryPicker, showAirportDir, showAdDir, showClickMapOnly, showMarker, showVecFeatureLayer, showAdvPlaces) { if (defCategory == undefined || defCategory == null || defCategory == '') { defCategory = defSelCategory; } initMap(mapContainer, latitude, longitude, zoom, description, defCategory, showCategories, showAirports, showPOIs, showClickMapOnly, showMarker, showVecFeatureLayer, showAdvPlaces) } //Custom QMap Functions function QMap_addLayers(mapObj, layers) { var firstLoad = false; if (mapObj.layers==null){firstLoad = true;} mapObj.layers = layers; var tmp = layers.split(","); for (var i = 0; i < tmp.length; i++) { switch(tmp[i]){ case "SAMap": if (SAMap) { SAMap.destroy(); } SAMap = new OpenLayers.Layer.MapServer( "Map", QWMSURL+"?QLayer=SAMap&Token='"+mapObj.token+"'", {layers: 'all'}, {'buffer': 0,'isBaseLayer': true} ); mapObj.map.addLayer(SAMap); break; case "Topo": if (Topo) { Topo.destroy(); } Topo = new OpenLayers.Layer.MapServer( "Topography", QWMSURL+"?QLayer=Topo&Token='"+mapObj.token+"'", {layers: 'all'}, {'buffer': 0,'isBaseLayer': false} ); mapObj.map.addLayer(Topo); break; case "Hybrid": if (Hybrid) { Hybrid.destroy(); } Hybrid = new OpenLayers.Layer.MapServer( "Hybrid", QWMSURL+"?QLayer=Hybrid&Token='"+mapObj.token+"'", {layers: 'all'}, {'buffer': 0,'isBaseLayer': false} ); mapObj.map.addLayer(Hybrid); break; case "StreetMap": if (StreetMap) { StreetMap.destroy(); } //StreetMap = new OpenLayers.Layer.WMS( "StreetMap", TileCacheURL.split(","), StreetMap = new OpenLayers.Layer.TileCache( "StreetMap", TileCacheURL2.split(","), //StreetMap = new OpenLayers.Layer.WMS( "StreetMap", QWMSURL+"?QLayer=StreetMap&Token='"+mapObj.token+"'", //StreetMap = new OpenLayers.Layer.WMS( "StreetMap", "http://wms.mapexchange.co.za/mapserver/mapserv.exe?map=D:\\www\\WMSMapServer\\ms4w\\apps\\StreetMap\\Streetmap.map&m&SERVICE=WMS&", "StreetMap", //{layers: 'StreetMap',transparent: 'false'}, {format:'image/jpeg','buffer': 0,'isBaseLayer': true,'displayInLayerSwitcher':false,'attribution': 'Data Provided by MapIT', transitionEffect:'resize'} ); mapObj.map.addLayer(StreetMap); // if (Labels) { Labels.destroy(); } // Labels = new OpenLayers.Layer.WMS( "QuarteX WMS", QWMSURL+"?QLayer=PolyLabels&Token='"+mapObj.token+"'", // {layers: 'StreetMap_Labels',transparent: 'true'}, // { singleTile: true, ratio: 1 }, // {'buffer': 0,'isBaseLayer': false,'displayInLayerSwitcher':false} // ); // mapObj.map.addLayer(Labels); break; } } //Check if we need to do the items that happen on first load if (firstLoad==true) { //Set the map center to the default lat & long mapObj.map.setCenter(new OpenLayers.LonLat(mapObj.lon, mapObj.lat), mapObj.zoom); //mapObj.map.addControl(new OpenLayers.Control.KeyboardDefaults()); mapObj.map.addControl(new OpenLayers.Control.MousePosition()); mapObj.map.addControl(new OpenLayers.Control.Scale()); mapObj.map.addControl(new OpenLayers.Control.PanZoomBar()); mapObj.map.addControl(new OpenLayers.Control.PanZoom()); mapObj.map.addControl(new OpenLayers.Control.Attribution()); mapObj.map.addControl(new OpenLayers.Control.Navigation()); mapObj.map.addControl(new OpenLayers.Control.ScaleLine()); } } function QMap_ZoomToPoint(mapObj, lat, lon, zoom) { //Set the map center to the default lat & long mapObj.map.setCenter(new OpenLayers.LonLat(lon, lat), zoom); } function QMap_AddMarker(mapObj, lat, lon, icon, size, opacity, content, isAnchor) { //Create the marker point var pnt = new OpenLayers.LonLat(lon, lat); var markers; if (mapObj.markers == null) { //Create the marker layer markers = new OpenLayers.Layer.Markers( "Markers" ); mapObj.markers = markers; mapObj.map.addLayer(markers); } else { markers = mapObj.markers; } var img; if (size==null) { img = new OpenLayers.Icon(icon); } else { img = new OpenLayers.Icon(icon, new OpenLayers.Size(size[0],size[1]), new OpenLayers.Pixel(-1*(size[0]/2), -1*size[1])); } var feature = new OpenLayers.Feature(SAMap, pnt); if (isAnchor == true) { anchorFeature = feature; } var marker = new OpenLayers.Marker(pnt,img); marker.setOpacity(opacity); //marker.events.register('mousedown', marker, function(evt) { QMap_PopUp(mapObj,feature,content,evt); }); marker.events.register('mouseover', marker, function(evt) { //debugger; try { try { mapObj.map.removePopup(popUpInfo); popUpInfo.destroy(); popUpInfo = null; } catch(e) { } popUpInfo = new OpenLayers.Popup.FramedCloud( "Info", feature.lonlat, null, content, null, true ); popUpInfo.calculateRelativePosition = function () { return 'bl'; } mapObj.map.addPopup(popUpInfo); } catch(ex) { } }); marker.events.register('mouseout', marker, function(evt) { try { //mapObj.map.removePopup(popUpInfo); //popUpInfo.destroy(); //popUpInfo = null; } catch(e) { } }); markers.addMarker(marker); } function QMap_PopUp(mapObj, feature, content, evt) { var markers = mapObj.markers; try { feature.destroyPopup(anchorPopup); } catch(e) { } anchorPopup = feature.createPopup(true); anchorPopup.setContentHTML(content); anchorPopup.setBackgroundColor("#DFDFFF"); anchorPopup.setOpacity(0.9); markers.map.addPopup(anchorPopup); if (evt !== undefined && evt !== null) { OpenLayers.Event.stop(evt); } } function QMap_ShowToolbar(mapObj, visible, toolbarDiv) { if(visible==true) { if(mapObj.Toolbar==null) { document.getElementById(toolbarDiv).className = 'olControlNavToolbar'; mapObj.Toolbar = new OpenLayers.Control.NavToolbar({'div':OpenLayers.Util.getElement(toolbarDiv)}); mapObj.map.addControl(mapObj.Toolbar); } } else { if(mapObj.Toolbar!=null) { mapObj.map.removeControl(mapObj.Toolbar); mapObj.Toolbar = null; } } } function QMap_ShowLayerSwitcher(mapObj, visible) { if(visible==true) { if(mapObj.LayerSwitcher==null) { mapObj.LayerSwitcher = new OpenLayers.Control.LayerSwitcher({activeColor:"669900"}); mapObj.map.addControl(mapObj.LayerSwitcher); } } else { if(mapObj.LayerSwitcher!=null) { mapObj.map.removeControl(mapObj.LayerSwitcher); mapObj.LayerSwitcher = null; } } } function QMap_ShowOverviewMap(mapObj, visible) { if(visible==true) { if(mapObj.OverviewMap==null) { mapObj.OverviewMap = new OpenLayers.Control.OverviewMap(); mapObj.map.addControl(mapObj.OverviewMap); } } else { if(mapObj.OverviewMap!=null) { mapObj.map.removeControl(mapObj.OverviewMap); mapObj.OverviewMap = null; } } } function FilterMapPOI(category) { if (showPOIs !== false) { completedPanAction = 0; var poiRadius = JQ('#' + mapPOIRadiusSel).val(); JQ('#imgPOILoading').css('display','inline'); JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetPOIs", data: {CategoryID: category, Latitude: mapObj.map.getCenter().lat, Longitude: mapObj.map.getCenter().lon, Radius: poiRadius}, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function(msg) { completedPanAction = 1; JQ('#imgPOILoading').css('display','none'); JQ('#' + mapPOISel).html(msg.d); }, error: function(msg) { completedPanAction = 1; JQ('#imgPOILoading').css('display','none'); JQ('#' + mapPOISel).html(''); } }); } if (showAdvertiserPlaces !== false) { if (AdvertiserPlaces) { AdvertiserPlaces.destroy(); } AdvertiserPlaces = new OpenLayers.Layer.WMS( "AdvertiserPlaces", QWMSURL+"?QLayer=AdvertiserPlaces&Token='"+mapObj.token+"'", {layers: 'AdvertiserPlaces', 'category': category, transparent: 'true'}, {'buffer': 0,'isBaseLayer': false,'gutter': 10,'displayInLayerSwitcher':false} ); mapObj.map.addLayer(AdvertiserPlaces); if (selectControl) { selectControl.destroy(); } selectControl = new OpenLayers.Control.Hover({ handlerOptions: { 'delay': 1000, 'pixelTolerance': 6 } }); mapObj.map.addControl(selectControl); selectControl.activate(); } } function AirportSelectionChanged(_poi) { if (showAirports !== false) { if (_poi == undefined || _poi == null) { _poi = JQ('#' + mapAirportSel).val(); } JQ('#' + mapPOIRdo).attr('checked', false); JQ('#' + mapAirportRdo).attr('checked', true); JQ('#' + mapAirportSel).val(_poi); SelectPOI(_poi,true); } } function POISelectionChanged(_poi) { if (showPOIs !== false) { JQ('#' + mapPOIRdo).attr('checked', true); JQ('#' + mapAirportRdo).attr('checked', false); JQ('#' + mapPOISel).val(_poi); SelectPOI(_poi); } } function DirectionsCheckChanged() { if (JQ('#' + mapPOIRdo).attr('checked') == true) { SelectPOI(JQ('#' + mapPOISel).val()); } else { SelectPOI(JQ('#' + mapAirportSel).val(), true); } } function SelectPOI(_poi, isAirport) { try { if (isAirport !== true) { poiSel = _poi; } var params = _poi.split(","); if (params.length > 2) { if (Routing) { Routing.destroy(); } var lat1,lon1,lat2,lon2; if (isAirport !== true) { lat1 = anchorLat; lon1 = anchorLon; lat2 = params[1]; lon2 = params[2]; } else { if (JQ('#' + mapAirportSelDir).val() == 'from') { lat1 = params[1]; lon1 = params[2]; lat2 = anchorLat; lon2 = anchorLon; } else { lat1 = anchorLat lon1 = anchorLon; lat2 = params[1]; lon2 = params[2]; } } JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetRouteDirections", data: {FrmLatitude: lat1, FrmLongitude: lon1, ToLatitude: lat2, ToLongitude: lon2}, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function(msg) { JQ('#' + txtDirections).val(msg.d); }, error: function(msg) { JQ('#' + txtDirections).val(''); } }); var bounds = new OpenLayers.Bounds(); bounds.extend(new OpenLayers.LonLat(anchorLon,anchorLat)); bounds.extend(new OpenLayers.LonLat(params[2],params[1])); mapObj.map.zoomToExtent(bounds); ShowPOIPopup(mapObj.map.getPixelFromLonLat(new OpenLayers.LonLat(params[2], params[1]))); if (routeLayer == undefined || routeLayer == null) { routeLayer = ''; } JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetRouteLayer", data: {FrmLatitude: lat1, FrmLongitude: lon1, ToLatitude: lat2, ToLongitude: lon2, RemoveLayer: JSON.stringify(routeLayer)}, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function(msg) { try { routeLayer = msg.d; if (routeLayer !== undefined && routeLayer !== null && routeLayer !== '') { //Routing = new OpenLayers.Layer.GML("GML", routeLayer, { style: {strokeColor: "#00FFFF", strokeWidth: 5} }); if (Routing) { Routing.destroy(); } Routing = new OpenLayers.Layer.WMS( "Routing", QWMSURL+"?QLayer=Routing&Token='"+mapObj.token+"'&RouteMap=" + routeLayer, {layers: 'Routing', transparent: 'true'}, {'buffer': 0,'isBaseLayer': false,'gutter': 10,'displayInLayerSwitcher':false} ); mapObj.map.addLayer(Routing); } } catch(e) {} }, error: function(msg) { } }); } else { JQ('#' + txtDirections).val(''); } } catch(e) { } } var completedPanAction = 1; function mapPanned(event) { if (showPOIs !== false) { if (completedPanAction == 1) { completedPanAction = 0; var category = defSelCategory; if (showCategories !== false) { category = JQ('#' + mapCategorySel).val(); } var poiRadius = JQ('#' + mapPOIRadiusSel).val(); JQ('#imgPOILoading').css('display','inline'); JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetPOIs", data: {CategoryID: category, Latitude: mapObj.map.getCenter().lat, Longitude: mapObj.map.getCenter().lon, Radius: poiRadius}, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function(msg) { completedPanAction = 1; JQ('#imgPOILoading').css('display','none'); JQ('#' + mapPOISel).html(msg.d); try { JQ('#' + mapPOISel).val(poiSel); } catch(e) { } }, error: function(msg) { JQ('#imgPOILoading').css('display','none'); JQ('#' + mapPOISel).html(''); completedPanAction = 1; } }); } } if (typeof QTX_MapPanned == 'function') { QTX_MapPanned(mapObj.map.getExtent().left, mapObj.map.getExtent().right, mapObj.map.getExtent().top, mapObj.map.getExtent().bottom); } } function LoadAirports() { JQ('#imgAirportLoading').css('display','inline'); JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetAirports", data: {Latitude: anchorLat, Longitude: anchorLon, MaxResults:3}, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function(msg) { JQ('#imgAirportLoading').css('display','none'); JQ('#' + mapAirportSel).html(msg.d); }, error: function(msg) { JQ('#imgAirportLoading').css('display','none'); JQ('#' + mapAirportSel).html(''); } }); } function ShowPOIPopup(xy) { var scale = mapObj.map.getScale(); if (scale < 150000){ curMousePos = xy; var selCategory = defSelCategory; if (showCategories !== false) { selCategory = JQ('#' + mapCategorySel).val(); } var latActual = mapObj.map.getLonLatFromViewPortPx(xy).lat; var lonActual = mapObj.map.getLonLatFromViewPortPx(xy).lon; var lat1 = latActual + (((scale / 1000) * 0.004) / 110); var lat2 = latActual - (((scale / 1000) * 0.004) / 110); var lon1 = lonActual + (((scale / 1000) * 0.004) / 110); var lon2 = lonActual - (((scale / 1000) * 0.004) / 110); if (anchorLat < lat1 && anchorLat > lat2 && anchorLon < lon1 && anchorLon > lon2 && anchorDesc !== undefined && anchorDesc !== null && anchorDesc !== '') { QMap_PopUp(mapObj, anchorFeature, anchorDesc); } JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetPOI", data: {CategoryID:selCategory, Latitude:latActual, Longitude:lonActual, Scale:scale, IsHereAboutSite:isHereAboutSite, ExtSiteAddress:JSON.stringify(extSiteAddress), IPAddress:JSON.stringify('34.204.191.31')}, dataType: "jsonp", success: function(msg) { try { if (msg.d !== '') { try { mapObj.map.removePopup(popUpInfo); popUpInfo.destroy(); popUpInfo = null; } catch(e) { } popUpInfo = new OpenLayers.Popup.FramedCloud( "Info", mapObj.map.getLonLatFromPixel(curMousePos), null, msg.d, null, true ); mapObj.map.addPopup(popUpInfo); } } catch(e) { } }, error: function(msg) { } }); } } function POIRadiusSelectionChanged(_poiRadius) { completedPanAction = 0; var category = defSelCategory; if (showCategories !== false) { category = JQ('#' + mapCategorySel).val(); } JQ('#imgPOILoading').css('display','inline'); JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/GetPOIs", data: {CategoryID: category, Latitude: mapObj.map.getCenter().lat, Longitude: mapObj.map.getCenter().lon, Radius: _poiRadius}, contentType: "application/json; charset=utf-8", dataType: "jsonp", success: function(msg) { completedPanAction = 1; JQ('#imgPOILoading').css('display','none'); JQ('#' + mapPOISel).html(msg.d); }, error: function(msg) { completedPanAction = 1; JQ('#imgPOILoading').css('display','none'); JQ('#' + mapPOISel).html(''); } }); } function mapZoomed(event) { if (showPOIs !== false) { if (mapObj.map.getZoom() == undefined || mapObj.map.getZoom() == null) { JQ('#' + mapPOIRadiusSel).val(5); } else if (mapObj.map.getZoom() > 7) { JQ('#' + mapPOIRadiusSel).val('5'); } else if (mapObj.map.getZoom() > 6) { JQ('#' + mapPOIRadiusSel).val('10'); } else if (mapObj.map.getZoom() > 4) { JQ('#' + mapPOIRadiusSel).val('20'); } else if (mapObj.map.getZoom() > 2) { JQ('#' + mapPOIRadiusSel).val('50'); } else { JQ('#' + mapPOIRadiusSel).val('100'); } POIRadiusSelectionChanged(JQ('#' + mapPOIRadiusSel).val()); } if (typeof QTX_MapZoomed == 'function') { QTX_MapZoomed(mapObj.map.getExtent().left, mapObj.map.getExtent().right, mapObj.map.getExtent().top, mapObj.map.getExtent().bottom); } } function mapPOIClickthrough(placeID) { JQ.ajax({ url: 'http://wms.mapexchange.co.za/WMSService.asmx' + "/POIClickthrough", data: {PlaceID:placeID, IsHereAboutSite:isHereAboutSite, ExtSiteAddress:JSON.stringify(extSiteAddress), IPAddress:JSON.stringify('34.204.191.31')}, dataType: "jsonp", success: function(msg) { }, error: function(msg) { } }); } function mapDisplayCopyrightAck() { alert('©MapIT. All cartographical data used in this product was supplied by MapIT, or Map Studio, a division of New Holland publishers (South Africa) (Proprietary) Limited and/or Georigin (Pty) Ltd. The copyright in all cartographical data including, but not limited to street centerline data, text, index material presented is owned by MapIT, Map Studio and Georigin, other than that compiled for this application by quartex technolgies (Pty) Ltd'); } function QTXDrawPoint(lat, lon, color) { try { var style_color = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']); style_color.strokeColor = color; style_color.fillColor = color; var layersFound = mapObj.map.getLayersByName('Features'); if (layersFound.length == 0) { mapObj.map.addLayer(vecFeatureLayer); } var point = new OpenLayers.Geometry.Point(lon, lat); var pointFeature = new OpenLayers.Feature.Vector(point,null,style_color); vecFeatureLayer.addFeatures(pointFeature); } catch(ex) { } } function QTXDrawCircle(lat, lon, radius) { try { var style_blue = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']); style_blue.strokeColor = "blue"; style_blue.fillColor = "blue"; var layersFound = mapObj.map.getLayersByName('Features'); if (layersFound.length == 0) { mapObj.map.addLayer(vecFeatureLayer); } var point = new OpenLayers.Geometry.Point(lon, lat); var circle = OpenLayers.Geometry.Polygon.createRegularPolygon(point, (radius * 1000) / ((6378137.0*(22/7))/ 180.0), 1000, 0); var circleFeature = new OpenLayers.Feature.Vector(circle,null,style_blue); vecFeatureLayer.addFeatures(circleFeature); } catch(ex) { } } function QTXDrawFeatures(geoJSONFeaturesCollection) { //try { var geojson_format = new OpenLayers.Format.GeoJSON(); var layersFound = mapObj.map.getLayersByName('Features'); if (layersFound.length == 0) { mapObj.map.addLayer(vecFeatureLayer); } vecFeatureLayer.addFeatures(geojson_format.read(geoJSONFeaturesCollection)); var options = { hover: true, onSelect: QTXVecFeatureSelected, onUnselect: QTXVecFeatureUnSelected }; if (selectVecFeature) selectVecFeature.destroy(); selectVecFeature = new OpenLayers.Control.SelectFeature(vecFeatureLayer, options); mapObj.map.addControl(selectVecFeature); selectVecFeature.activate(); var bounds = new OpenLayers.Bounds(); for (var ind=0; ind < vecFeatureLayer.features.length; ind++) { bounds.extend(new OpenLayers.LonLat(vecFeatureLayer.features[ind].geometry.bounds.left, vecFeatureLayer.features[ind].geometry.bounds.top)); mapObj.map.zoomToExtent(bounds); } //} //catch(ex) {} } function QTXVecFeatureSelected(feature) { try { var str = new OpenLayers.Format.GeoJSON().write(feature, true); try { mapObj.map.removePopup(popUpInfo); popUpInfo.destroy(); popUpInfo = null; } catch(e) { } popUpInfo = new OpenLayers.Popup.FramedCloud( "Info", feature.geometry.getBounds().getCenterLonLat(), null, feature.attributes["description"], null, true ); mapObj.map.addPopup(popUpInfo); } catch(ex) { } } function QTXVecFeatureUnSelected(feature) { try { mapObj.map.removePopup(popUpInfo); popUpInfo.destroy(); popUpInfo = null; } catch(e) { } } function QTXDestroyVecFeatureLayer() { try { if (vecFeatureLayer) { vecFeatureLayer.eraseFeatures(vecFeatureLayer.features); for (var ind=vecFeatureLayer.features.length-1; ind >= 0; ind--) { vecFeatureLayer.features[ind].destroy(); } } } catch(ex) {} } function QTXDestroyMarkerLayer() { try { if (mapObj.markers) { mapObj.markers.clearMarkers(); } } catch(ex) {} } function LoadPlaceSummary(divContainerName, placeID, zoom, categoryID) { var topPos = (JQ(window).height() - 400) /2; var leftPos = (JQ(window).width() - 910) /2; if (topPos < 0) { topPos = 0; } if (leftPos < 0) { leftPos = 0; } JQ('#' + divContainerName).css('display','none'); JQ('#' + divContainerName).html('
[Close]