function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("googlemap")); map.enableScrollWheelZoom(); $("input[@name=sq_office], input[@name=sq_shop], input[@name=sq_storage], input[@name=sq_basement], #countrypart").change(function () { loadPositions(map); }); $("#countrypart").change(function(){ switch ($("#countrypart").attr("value")) { case "2" : bounds = getBoundsObjectFromString("((54.68653423452969, 10.0030517578125), (56.05363501913436, 13.282470703125))"); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); break; case "3" : bounds = getBoundsObjectFromString("((54.90346138168996, 9.45648193359375), (55.5892112606541, 11.09619140625))"); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); break; case "4" : bounds = getBoundsObjectFromString("((55.05162926954485, 8.11614990234375), (55.73484280305742, 9.755859375))"); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); break; case "5" : bounds = getBoundsObjectFromString("((55.466399363938194, 7.822265625), (56.806893398067466, 11.1016845703125))"); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); break; case "6" : bounds = getBoundsObjectFromString("((56.40478400265929, 8.206787109375), (57.712951011135694, 11.4862060546875))"); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); break; default : map.setCenter(center, 5); break; } }); var center = new GLatLng( 55.8, 11.2); map.addControl(new GSmallMapControl()); //alert($("#map_bounds").attr("value")); GEvent.addListener(map, "moveend", function() { $("#map_bounds").attr("value", map.getBounds().toString()); loadAvailableApartments(); }); if ($("#map_bounds").attr("value") == undefined) map.setCenter(center, 5); else { bounds = getBoundsObjectFromString($("#map_bounds").attr("value")); //alert(bounds.getCenter()); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); } loadPositions(map); } } function getBoundsObjectFromString(str) { arr = str.split("), ("); ne = arr[0].substr(2); sw = arr[1].substr(0, arr[1].length-2); obj = new GLatLngBounds(GLatLng.fromUrlValue(ne), GLatLng.fromUrlValue(sw)); return obj; } function unundef(val) { if (val == undefined) return ""; return val; } function loadPositions(map) { // hent nyt datasæt $.getJSON("http://hdejendomme-erhverv.dk/search/js_available_apartments_positions", { "sq_office" : unundef( $("input[@name=sq_office]").attr("checked") ? "1" : "0" ), "sq_shop" : unundef( $("input[@name=sq_shop]").attr("checked") ? "1" : "0"), "sq_storage" : unundef( $("input[@name=sq_storage]").attr("checked") ? "1" : "0" ), "sq_basement" : unundef( $("input[@name=sq_basement]").attr("checked") ? "1" : "0" ), "countrypart" : unundef( $("#countrypart").attr("value") ) }, function(json){ map.clearOverlays(); for (i in json) { //alert(i); marker = createMarker(json[i]); map.addOverlay(marker); } }); loadAvailableApartments(); } function loadAvailableApartments() { $.getJSON("http://hdejendomme-erhverv.dk/search/js_available_apartments_count", { "map_bounds" : unundef( $("#map_bounds").attr("value") ), "sq_office" : unundef( $("input[@name=sq_office]").attr("checked") ? "1" : "0" ), "sq_shop" : unundef( $("input[@name=sq_shop]").attr("checked") ? "1" : "0" ), "sq_storage" : unundef( $("input[@name=sq_storage]").attr("checked") ? "1" : "0" ), "sq_basement" : unundef( $("input[@name=sq_basement]").attr("checked") ? "1" : "0" ), "countrypart" : unundef( $("#countrypart").attr("value") ) },function(json){ $("#apartment_count").html(json.count); }); // hent antal ledige lejemål } // Create our "tiny" marker icon var icon = new GIcon(); icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png"; icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon.iconSize = new GSize(12, 20); icon.shadowSize = new GSize(22, 20); icon.iconAnchor = new GPoint(6, 20); icon.infoWindowAnchor = new GPoint(5, 1); // Create our "tiny" marker icon var icon2 = new GIcon(); icon2.image = "http://labs.google.com/ridefinder/images/mm_20_green.png"; icon2.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; icon2.iconSize = new GSize(12, 20); icon2.shadowSize = new GSize(22, 20); icon2.iconAnchor = new GPoint(6, 20); icon2.infoWindowAnchor = new GPoint(5, 1); function createMarker(info) { var point = new GLatLng( info.latitude, info.longitude); if (info.available == '1') { var marker = new GMarker(point, {'icon': icon2}); } else { var marker = new GMarker(point, {'icon': icon}); } GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml('