How to search an address ?
Hello,
I try to use "nokia.maps.search.Address()" But is not working and i do not find any example about this interface.
Could you help me ?
my code is :
[HTML]
var mapContainer = document.getElementById("mapContainer");
var map = new nokia.maps.map.Display(mapContainer, {
// initial center and zoom level of the map
components: [
new nokia.maps.search.Address({
country: 'France',
})
]
});
[/HTML]
Thanks
Re: How to search an address ?
What excatly would you want to do ? If you simply want to know location for an address, then You could also check teh geo coding part of the API.
Re: How to search an address ?
Hello symbianyucca,
Thank you for your help.
I saw that nokia.maps.search.Address() disappear on Nokia Maps API Reference 2.2.1 !
I would like to find a point on the map not with Coordinates ([52.51, 13.4]) but with an address (10178 Berlin, Germany).
I tried to find a solution on the geo coding part of the API, but i can't find an option with searching address !
I understood that the code for searching a point with coordinates is :
[HTML]
var map = new nokia.maps.map.Display(document.getElementById("mapContainer"), {
// Zoom level for the map
'zoomLevel': 10,
// Map center coordinates
'center': [52.51, 13.4]
});
[/HTML]
But how to do with an address (10178 Berlin, Germany) ?
Re: How to search an address ?
You could check the definition for Geo Coding: [url]http://en.wikipedia.org/wiki/Geocoding[/url] ,its really for finding coordinates with address information..
Wiki would have some stuff for it: [url]http://www.developer.nokia.com/Community/Wiki/Nokia_Maps_API_-_Using_the_geocoding_service[/url] and do check the docs & playground.
Re: How to search an address ?
I found it with an other way !
thanks for you time!
Here my code
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php $map_height = "height: 340px";
$map_width = "width: 310px";
$adresse = '33210 MAZÈRES, France';
?>
<head>
<title>My first Nokia Maps web page</title>
<link rel="stylesheet" type="text/css" href="http://api.maps.nokia.com/en/playground/exampleHelpers.css"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="http://api.maps.nokia.com/2.2.1/jsl.js?with=all" charset="utf-8"></script>
<script type="text/javascript" charset="UTF-8" src="http://api.maps.nokia.com/en/playground/exampleHelpers.js"></script>
<style type="text/css">
html {
overflow:hidden;
}
body {
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
position: absolute;
}
#mapContainer {
width: 100%;
height: 100%;
left: 0;
top: 0;
position: absolute;
}
</style>
</head>
<body>
<h1>My first Nokia Map!</h1>
<!--<div id="mapContainer" style="width:310px; height:340px;"></div>-->
<div id="mapContainer"></div>
<script type="text/javascript">
/////////////////////////////////////////////////////////////////////////////////////
// http://api.maps.nokia.com/en/index.html
//
nokia.Settings.set( "appId", "");
nokia.Settings.set( "authenticationToken", "");
//
/////////////////////////////////////////////////////////////////////////////////////
//nokia.Settings.set("defaultLanguage", "de-DE");
nokia.Settings.set("defaultLanguage", "fr-FR");
// Get the DOM node to which we will append the map
var mapContainer = document.getElementById("mapContainer");
// We create a new instance of InfoBubbles bound to a variable so we can call it later on
var infoBubbles = new nokia.maps.map.component.InfoBubbles();
// Create a map inside the map container DOM node
var map = new nokia.maps.map.Display(mapContainer, {
// initial center and zoom level of the map
center: [52.51, 13.4],
zoomLevel: 10,
components:[
// We add the behavior component to allow panning / zooming of the map
new nokia.maps.map.component.Behavior(),
infoBubbles
]
});
var addresses = [
"France", // Brandenburger Tor
"69005 lyon, france", // Fernsehturm
"Friedrichstr. 44, 10969 Berlin" // Checkpoint Charlie
],
// We will put our address markers into this container zo we can zoom in to the markers
addressesContainer = new nokia.maps.map.Container(),
marker,
searchCenter = new nokia.maps.geo.Coordinate(52.51, 13.4),
searchManager = nokia.places.search.manager,
i = 0 ,
len = requests = addresses.length;
map.objects.add(addressesContainer);
var processResults = function (data, requestStatus, requestId) {
// Data is instance of nokia.places.objects.Place
var location = data.location;
// Ensure that we our request came back with valid result
if (requestStatus == "OK") {
// Create a new marker on the found location
marker = new nokia.maps.map.StandardMarker(location.position);
// Add marker to its container so it will be render
addressesContainer.objects.add(marker);
/* We store the address from the location and name of the
* Place object in the marker so we can create an infoBubble
* with this information on click.
*/
marker.$address = location.address;
marker.$label = data.name;
}
};
/* We use nokia.places.search.manager.geCode to translate
* the given address to a nokia.places.objects.Place which
* contains the longitude and latitude
*/
for (; i < len; i++) {
searchManager.geoCode({
searchTerm: addresses[i],
onComplete: function (data, requestStatus, requestId) {
processResults(data, requestStatus, requestId);
requests--;
if (requests == 0) {
map.zoomTo(addressesContainer.getBoundingBox());
}
}
});
}
</script>
</body>
</html>
[/HTML]
Re: How to search an address ?
Yep, same thing anyway, its using the [B]searchManager.geoCode[/B] in the end.
Re: How to search an address ?
hello symbianyucca,
thanks for the link with the method "nokia.places.search.manager.findPlaces()". It is a good idea, i will certainly use for future code.
I have another question.
In my last code when I search an address, the zoom is on the max (street)
Il would like to change it. Do you have an idea ?
[HTML]
var addresses = [
"Friedrichstr. 44, 10969 Berlin" //
],
// We will put our address markers into this container zo we can zoom in to the markers
addressesContainer = new nokia.maps.map.Container(),
marker,
searchCenter = new nokia.maps.geo.Coordinate(52.51, 13.4),
searchManager = nokia.places.search.manager,
i = 0 ,
len = requests = addresses.length;
[/HTML]
Re: How to search an address ?
Basically the API does have function for changing the Zoom level, so not understanding on what the problem on utilizing it is ?
Re: How to search an address ?
sorry i was not clear.
The "zoomlevel" on nokia.maps.map.Display is the initial zoom.
But when I search automatically an address with my "var addresses" the zoom change, to be at the max (20).
I want to zoom in to the marker (my address) but not too much... (for example : 5)
Do you have an idea ?
Here my page
[url]http://www.concourslyon.com/b_map_nokia3.php[/url]
Re: How to search an address ?
basically, there is no magic happening, you are calling [B]map.zoomTo(addressesContainer.getBoundingBox());[/B] to zoom the map. So if you have only one item, it will zoom to max. So you should change your logic to handle the situation differently.
Re: How to search an address ?
ok thank you i will work on it !