Created
September 17, 2014 06:59
-
-
Save deguchi/1505fbce712b826a4971 to your computer and use it in GitHub Desktop.
OpenStreetMapを使ったジオコーディング
This file contains 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
$('#map_search').submit -> | |
url = 'http://nominatim.openstreetmap.org/search' | |
$.ajax | |
url: url | |
type: "GET" | |
data: | |
q: $('#map_query').val() | |
format: "json" | |
dataType: "jsonp" | |
jsonp: "json_callback" | |
error: ()-> | |
success: (data)=> | |
log data | |
if data.length>0 | |
haika.options.lon = parseFloat(data[0].lon) | |
haika.options.lat = parseFloat(data[0].lat) | |
haika.save() | |
$('#canvas_lon').val haika.options.lon | |
$('#canvas_lat').val haika.options.lat | |
center = ol.proj.transform([ haika.options.lon, haika.options.lat ], "EPSG:4326", "EPSG:3857") | |
view = map.getView() | |
view.setCenter(center) | |
view.setZoom(20) | |
else | |
alert '見つかりませんでした。' | |
return false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment