﻿var startLocation = new Microsoft.Maps.Location(59.9803, 14.1705); var layer; var ZeroForUnauth; var map; function LoadGeoRSS(url, doCenterAndZoom) { map.entities.clear(); var polylineOptions = { fillColor: new Microsoft.Maps.Color(156, 0, 0, 255) }; var polygonOptions = { fillColor: new Microsoft.Maps.Color(156, 0, 0, 255), strokeColor: new Microsoft.Maps.Color(156, 0, 255, 0) }; var layer = new GeoRSSLayer(null, polylineOptions, polygonOptions); layer.LoadGeoRSS(url, function (items) { map.entities.push(items); if (doCenterAndZoom) { map.setView({ bounds: layer.GetBounds() }) } }) } function clearInfoBox() { var ibTitle = document.getElementById('ibTitle'); ibTitle.innerHTML = ""; var ibDescription = document.getElementById('ibDescription'); ibDescription.innerHTML = "" } function zoomCity(lat, lon, cityId, stad) { clearInfoBox(); map.entities.clear(); var time = new Date().getTime(); var id = cityId + "," + time; ZeroForUnauth = $get("addId").value; var request = "/RetrieveService.svc/GetPolygon/" + id; $get("NavRubrik").innerHTML = stad; LoadGeoRSS(request, true); var location = new Microsoft.Maps.Location(lat, lon); map.setView({ zoom: 10, center: location }) } function showLatestAdds(doCenterAndZoom) { var time = new Date().getTime(); var aid = $get("addId").value + "," + time; ZeroForUnauth = $get("addId").value; var link = "/RetrieveService.svc/GetPolygon/" + aid; LoadGeoRSS(link, doCenterAndZoom) } function pageLoad() { map = new Microsoft.Maps.Map(document.getElementById('startMap'), { enableClickableLogo: false, enableSearchLogo: false, showMapTypeSelector: false, credentials: 'AnwP-2xCpJLa8B-N7v13fkrFcmNfrq41C71hDO85r2xvQLjO9Yd6GtL8UtI3bCOe', center: new Microsoft.Maps.Location(59.9803, 14.1705), zoom: 5 }); var city = $get("city").value; switch (city) { case "sthlm": zoomCity(59.32793572139082, 18.063583374023444, 1, 'Senast i Stockholm'); break; case "gbg": zoomCity(57.70011145457481, 11.96754455566406, 2, 'Senast i Göteborg'); break; default: showLatestAdds(false) } } function WindowMouseWheelHandler(e) { e.stopPropagation(); e.preventDefault(); e.cancelBubble = false; return false } function openwindow(target) { window.open(target, "_blank", "status=1,scrollbars=1,toolbar=1,resizable=1,menubar=0,location=0") }
