Last active
September 5, 2016 04:37
-
-
Save ynunokawa/8ec5c70d089a55bcabf7e3fd5dce9e39 to your computer and use it in GitHub Desktop.
無料 wifi スポット
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
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>無料 wifi スポット</title> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<!-- Load Leaflet from CDN--> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet.css" /> | |
<script src="https://cdn.jsdelivr.net/leaflet/1.0.0-rc.3/leaflet-src.js"></script> | |
<!-- Load Esri Leaflet from CDN --> | |
<script src="https://cdn.jsdelivr.net/leaflet.esri/2.0.2/esri-leaflet.js"></script> | |
<style> | |
body { margin:0; padding:0; } | |
#map { position: absolute; top:0; bottom:0; right:0; left:0; } | |
</style> | |
</head> | |
<body> | |
<div id="map"></div> | |
<script> | |
var resultLatlng = getLatlng(); | |
var r = 500; | |
var titleFieldName = 'スポット名_日本語_'; | |
/*L.Map = L.Map.extend({ | |
openPopup: function(popup) { | |
this._popup = popup; | |
return this.addLayer(popup).fire('popupopen', { | |
popup: this._popup | |
}); | |
} | |
});*/ | |
var map = L.map('map').setView(resultLatlng, 16); | |
var filterResults = L.geoJson(null, { | |
onEachFeature: function (feature, layer) { | |
layer.bindPopup('<a target="_brank" href="https://www.google.co.jp/#q=' + feature.properties[titleFieldName] + '">' + feature.properties[titleFieldName] + '</a>'); | |
} | |
}).addTo(map); | |
var results = L.layerGroup().addTo(map); | |
L.esri.basemapLayer("Streets").addTo(map); | |
results.addLayer(L.circle(resultLatlng, r, { | |
color: '#ff6600', | |
fillColor: '#ff6600', | |
weight: 1, | |
dashArray: [5, 5] | |
})); | |
var query = L.esri.query({ | |
url: 'https://services3.arcgis.com/iH4Iz7CEdh5xTJYb/arcgis/rest/services/free_wifi_U8/FeatureServer/0' | |
}); | |
query.nearby(resultLatlng, r); | |
query.run(function(error, featureCollection, response){ | |
filterResults.addData(featureCollection); | |
}); | |
function getLatlng() { | |
var latlng = [35.681, 139.74]; | |
var urlParams = location.search.substring(1).split('&'); | |
for(var i=0; urlParams[i]; i++) { | |
var param = urlParams[i].split('='); | |
if(param[0] === 'lat') { | |
latlng[0] = param[1]; | |
} | |
else if (param[0] === 'lng') { | |
latlng[1] = param[1]; | |
} | |
} | |
return latlng; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment