-
-
Save jacobandresen/cc132b70797422d319cd to your computer and use it in GitHub Desktop.
dawa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var search ="http://dawa.aws.dk/adresser"; | |
$( "#address" ).autocomplete({ | |
source: function( request, response ) { | |
$.ajax({ | |
url : search, | |
dataType: "jsonp", | |
data: { | |
q: $('#address').val() + "*", | |
format: "geojson" | |
}, | |
success: function( data ) { | |
response ( $.map( data.features, function ( item) { | |
return { | |
geometry: item.geometry, | |
label: item.properties.vejnavn + " " + item.properties.husnr + "," + item.properties.kommunenavn, | |
value: item.properties.vejnavn + " " + item.properties.husnr + "," + item.properties.kommunenavn, | |
id: item.properties.id | |
}; | |
})); | |
} | |
}); | |
}, | |
minLength: 2, | |
select: function( event, ui ) { | |
var coord = ui.item.geometry.coordinates; | |
var marker = L.marker([coord[1], coord[0]]).addTo(map); | |
map.setView(L.latLng(coord[1], coord[0]), 15); | |
}, | |
open: function() { | |
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); | |
}, | |
close: function() { | |
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hej Jacob - har du også lavet koden til Openlayers 3. Jeg forsøger at lave en adressesøgningsfunktion i et OL3 kort med DAWA data, men er lidt lost. Mvh Jan