[OpenLayers-Users] Geocoding in Spherical mercator
David Martinez Morata
damarmo at gmail.com
Thu Jul 3 09:30:45 EDT 2008
Thanks for your help.
Diego I try this:
function showAddress(address) {
var geocoder = new GClientGeocoder();
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {alert(address + " not found");}
else
{map.setCenter(OpenLayers.Layer.SphericalMercator.forwardMercator(point.x,point.y),15)}
}
);
}
}
And thats Works. Thanks!
2008/7/3 Paul Spencer <pagameba at gmail.com>:
> Try this:
>
> var mapProj = new OpenLayers.Projection('EPSG:900913');
> var userProj = new OpenLayers.Projection('EPSG:4326');
>
> function showAddress(address) {
> var geocoder = new GClientGeocoder();
> if (geocoder) {
> geocoder.getLatLng(
> address,
> function(point) {
> if (!point) {
> alert(address + " not found");
> } else {
> var ll = new OpenLayers.LonLat(point.x,point.y);
> ll.transform(userProj, mapProj);
> map.setCenter(ll,15);
> }
> }
> );
> }
> }
>
> Cheers
>
> Paul
>
>
> On 3-Jul-08, at 8:07 AM, David Martinez Morata wrote:
>
> Hello.
>> I have a problem with geocoding.
>>
>> I have a function to do it, but the problem its the result. I geocode and
>> the result it's in EPSG:4326 projection but mi map it's in EPSG:900913. I
>> try to put the transform function of OpenLayers.LonLat object but I'm doing
>> somthing wrong.
>> My function it's:
>>
>>
>> function showAddress(address) {
>> var geocoder = new GClientGeocoder();
>> if (geocoder) {
>> geocoder.getLatLng(
>> address,
>> function(point) {
>> if (!point) {alert(address + " not found");}
>> else {map.setCenter(new OpenLayers.LonLat(point.x,point.y),15)}
>> }
>> );
>> }
>> }
>>
>> Anyone can help me?
>>
>> Thanks
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080703/e2314ae6/attachment.html
More information about the Users
mailing list