[Commits] r2100 - sandbox/cmoullet/publicapi
commits at geoext.org
commits at geoext.org
Tue Apr 20 15:29:48 CEST 2010
Author: cmoullet
Date: 2010-04-20 15:29:47 +0200 (Tue, 20 Apr 2010)
New Revision: 2100
Added:
sandbox/cmoullet/publicapi/map_bing_geocoding.html
sandbox/cmoullet/publicapi/map_google_geocoding.html
sandbox/cmoullet/publicapi/map_map24_geocoding.html
sandbox/cmoullet/publicapi/map_yahoo_geocoding.html
Modified:
sandbox/cmoullet/publicapi/index.html
sandbox/cmoullet/publicapi/map_bing.html
sandbox/cmoullet/publicapi/map_google.html
sandbox/cmoullet/publicapi/map_map24.html
sandbox/cmoullet/publicapi/map_yahoo.html
Log:
Add geocoding examples
Modified: sandbox/cmoullet/publicapi/index.html
===================================================================
--- sandbox/cmoullet/publicapi/index.html 2010-04-20 10:54:12 UTC (rev 2099)
+++ sandbox/cmoullet/publicapi/index.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -24,7 +24,14 @@
<li><a href="map_map24.html">Map24</a></li>
<li><a href="map_ign.html">IGN</a></li>
+<h2>Géocodage</h2>
+<li><a href="map_google_geocoding.html">Google Maps</a></li>
+<li><a href="map_yahoo_geocoding.html">Yahoo Maps</a></li>
+<li><a href="map_bing_geocoding.html">Bing Maps</a></li>
+<li><a href="map_map24_geocoding.html">Map24</a></li>
+<li>IGN: pas directement intégré à l'API, mais propose un service <a href="https://api.ign.fr/geoportail/presentation.do?presentationSubjectId=4">"données IGN"</a></li>
+
</body>
</html>
Modified: sandbox/cmoullet/publicapi/map_bing.html
===================================================================
--- sandbox/cmoullet/publicapi/map_bing.html 2010-04-20 10:54:12 UTC (rev 2099)
+++ sandbox/cmoullet/publicapi/map_bing.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -2,7 +2,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
- <title>Bing Map</title>
+ <title>Bing Maps</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>
Added: sandbox/cmoullet/publicapi/map_bing_geocoding.html
===================================================================
--- sandbox/cmoullet/publicapi/map_bing_geocoding.html (rev 0)
+++ sandbox/cmoullet/publicapi/map_bing_geocoding.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -0,0 +1,38 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.2"></script>
+ <script type="text/javascript">
+ var map = null;
+
+ function GetMap()
+ {
+ map = new VEMap('myMap');
+ map.SetCredentials("Aq5iKX74RozeorqtIW44_gdknjehuo-f8HHsKsg0U-xVSq-9PPBMc75zqD3-fpKy");
+ map.LoadMap();
+
+ }
+
+
+ function FindLoc()
+ {
+ try
+ {
+ map.Find(null, document.getElementById("txtWhere").value);
+ }
+ catch(e)
+ {
+ alert(e.message);
+ }
+ }
+ </script>
+</head>
+<body onload="GetMap();">
+<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
+<INPUT id="txtWhere" type="text" name="txtWhere">
+<INPUT id="find" type="button" value="Find" name="find" onclick="FindLoc();">
+</body>
+</html>
Modified: sandbox/cmoullet/publicapi/map_google.html
===================================================================
--- sandbox/cmoullet/publicapi/map_google.html 2010-04-20 10:54:12 UTC (rev 2099)
+++ sandbox/cmoullet/publicapi/map_google.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -1,6 +1,6 @@
<html>
<head>
- <title>Google Map</title>
+ <title>Google Maps</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false&key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA"></script>
Added: sandbox/cmoullet/publicapi/map_google_geocoding.html
===================================================================
--- sandbox/cmoullet/publicapi/map_google_geocoding.html (rev 0)
+++ sandbox/cmoullet/publicapi/map_google_geocoding.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -0,0 +1,47 @@
+<html>
+<head>
+ <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ <title>Google Maps: geocoding</title>
+ <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&key=ABQIAAAAY-I0w1WyNCVHbxpuwQWMpRTv_-xvSZ6KJmWSkQfCJoxbiB7tyBQ1ey_kgwA_p7sbTQSTOBeMyXtXkA"></script>
+ <script type="text/javascript">
+ var geocoder;
+ var map;
+ function initialize() {
+ geocoder = new google.maps.Geocoder();
+ var latlng = new google.maps.LatLng(-34.397, 150.644);
+ var myOptions = {
+ zoom: 8,
+ center: latlng,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+ map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+ }
+
+ function codeAddress() {
+ var address = document.getElementById("address").value;
+ if (geocoder) {
+ geocoder.geocode({ 'address': address}, function(results, status) {
+ if (status == google.maps.GeocoderStatus.OK) {
+ map.setCenter(results[0].geometry.location);
+ var marker = new google.maps.Marker({
+ map: map,
+ position: results[0].geometry.location
+ });
+ } else {
+ alert("Geocode was not successful for the following reason: " + status);
+ }
+ });
+ }
+ }
+ </script>
+</head>
+<body style="margin:0px; padding:0px;" onload="initialize()">
+<div>
+ <input id="address" type="textbox" value="Sydney, NSW">
+ <input type="button" value="Geocode" onclick="codeAddress()">
+
+</div>
+<div id="map_canvas" style="width:100%; height:90%"></div>
+</body>
+</html>
Modified: sandbox/cmoullet/publicapi/map_map24.html
===================================================================
--- sandbox/cmoullet/publicapi/map_map24.html 2010-04-20 10:54:12 UTC (rev 2099)
+++ sandbox/cmoullet/publicapi/map_map24.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -3,7 +3,7 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
- <title>Hello World</title>
+ <title>Map24</title>
<script type="text/javascript" language="javascript"
src="http://api.maptp.map24.com/ajax?appkey=FJX8bd693e2c0784ae3a9e86908121c7X50">
</script>
Added: sandbox/cmoullet/publicapi/map_map24_geocoding.html
===================================================================
--- sandbox/cmoullet/publicapi/map_map24_geocoding.html (rev 0)
+++ sandbox/cmoullet/publicapi/map_map24_geocoding.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+ <title>Geocoding</title>
+
+ <script type="text/javascript" language="JavaScript" type="text/javascript"
+ src="http://api.maptp.map24.com/ajax?appkey=FJX8bd693e2c0784ae3a9e86908121c7X50"></script>
+ <script type="text/javascript" language="JavaScript" type="text/javascript">
+
+ function goMap24() {
+ Map24.loadApi(["core_api", "wrapper_api"], map24ApiLoaded);
+ }
+
+ function map24ApiLoaded() {
+ Map24.MapApplication.init({ NodeName: "maparea" });
+ document.getElementById('button_search').disabled = false;
+ }
+
+ //Geocode an address.
+ //The address is provided in the searchText parameter as free text.
+ function geocode(searchText) {
+ if (Map24.trim(searchText) == "") {
+ alert("Please enter an address.");
+ return;
+ }
+
+ var geocoder = new Map24.GeocoderServiceStub();
+ //Geocodes the address. The address is passed in the Search field. The Alternatives field defines the number
+ //of geocoded addresses that are returned in the response. You must pass the name of the callback function
+ //that is called as soon as the client has received the response.
+ geocoder.geocode({ SearchText: Map24.trim(searchText), MaxNoOfAlternatives: 10, CallbackFunction: printResult });
+ }
+
+ //Callback function that is called after the client has received the response.
+ //This function accesses the array of geocoded addresses and shows them in a list.
+ //The elements of this array are objects of the type Map24.Location.
+ function printResult(locs) {
+ //Center the map view on the first element in the array of geocoded addresses. A Map24.Location object has several
+ //methods and properties which you can find in the API documentation for the corresponding class.
+ Map24.MapApplication.center({
+ Longitude: locs[0].getLongitude(), Latitude: locs[0].getLatitude(), MinimumWidth: 2500
+ });
+
+ //Create a list that shows the results.
+ var result = "<br /><center><b>Search results:</b></center><hr />";
+
+ //Iterate through the array of locations.
+ for (var i = 0; i < locs.length; i++) {
+
+ //Output all relevant properties of all locations.
+ result += "<b>Result Nr." + (i + 1) + "</b><br />";
+
+ result += "Longitude " + [i + 1] + ": " + locs[i].getLongitude() + "<br />";
+ result += "Latitude " + [i + 1] + ": " + locs[i].getLatitude() + "<br />";
+
+ result += "City: " + locs[i].getCity() + "<br />";
+ result += "Zip: " + locs[i].getZip() + "<br />";
+ result += "County: " + locs[i].getCounty() + "<br />";
+ result += "State: " + locs[i].getState() + "<br />";
+ result += "Country: " + locs[i].getCountry() + "<br />";
+ result += "<input type=\"button\" value=\"Center on Result\" onclick=\"Map24.MapApplication.center( {Longitude: " + locs[i].getLongitude() + ", Latitude: " + locs[i].getLatitude() + "});\" />";
+ result += "<hr/>";
+ }
+ document.getElementById("geocodingresults").innerHTML = result;
+ }
+
+ </script>
+</head>
+
+<body onload="goMap24()">
+<div id="maparea" style="width:700px;height:500px;background-color:#E0E0E0;"></div>
+<b>Address: </b><input id="address_field" type="text" style="margin-top:8px" size="40" maxlength="50"/>
+<br/>
+<input type="submit" style="margin-top:5px" value="Search" id="button_search" disabled="disabled"
+ onclick="return geocode( document.getElementById('address_field').value )"/>
+<br/>
+<br/>
+
+<div id="geocodingresults" style="width:700px;background-color:#E0E0E0;"></div>
+</body>
+</html>
\ No newline at end of file
Modified: sandbox/cmoullet/publicapi/map_yahoo.html
===================================================================
--- sandbox/cmoullet/publicapi/map_yahoo.html 2010-04-20 10:54:12 UTC (rev 2099)
+++ sandbox/cmoullet/publicapi/map_yahoo.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -1,6 +1,6 @@
<html>
<head>
- <title>Yahho Map</title>
+ <title>Yahoo Map</title>
<script type="text/javascript"
src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=7hkG5l3V34FMXizccH3TD3aYPurAC1U_irE.81LMyWruKFx2WpHgFN6tshTBrP0HN2GEq1k-"></script>
<style type="text/css">
Added: sandbox/cmoullet/publicapi/map_yahoo_geocoding.html
===================================================================
--- sandbox/cmoullet/publicapi/map_yahoo_geocoding.html (rev 0)
+++ sandbox/cmoullet/publicapi/map_yahoo_geocoding.html 2010-04-20 13:29:47 UTC (rev 2100)
@@ -0,0 +1,29 @@
+<html>
+<head>
+ <script type="text/javascript"
+ src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=7hkG5l3V34FMXizccH3TD3aYPurAC1U_irE.81LMyWruKFx2WpHgFN6tshTBrP0HN2GEq1k-"></script>
+ <style type="text/css">
+ map {
+ height: 75%;
+ width: 100%;
+ }
+ </style>
+</head>
+<body>
+<div id="map"></div>
+
+<script type="text/javascript">
+ // Create a map object
+ var map = new YMap(document.getElementById('map'));
+
+ // Add map type control
+ map.addTypeControl();
+
+ // Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB, YAHOO_MAP_REG
+ map.setMapType(YAHOO_MAP_REG);
+
+ // Display the map centered on a geocoded location
+ map.drawZoomAndCenter("Sydney, NSW", 3);
+</script>
+</body>
+</html>
\ No newline at end of file
More information about the Commits
mailing list