Skip to content

Instantly share code, notes, and snippets.

@jacobandresen
Created June 17, 2014 22:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobandresen/cc132b70797422d319cd to your computer and use it in GitHub Desktop.
Save jacobandresen/cc132b70797422d319cd to your computer and use it in GitHub Desktop.
dawa
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" );
}
});
@janhvingel
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment