[OpenLayers-Users] Temporary point from lonlat

Lehtonen, Mika mika at digikartta.net
Wed Mar 4 02:07:43 EST 2009


Hi Hugo,

I have this function in one of my applications. markers is a marker 
layer. Just started to wonder where that clearMarkers( ) is coming from. 
It's not part of the API, is it? Anyway, this function works  for me. 
Maybe you can get some ideas out of it anyway.

- mika -

function showAddress(address)    {
                    var size = new OpenLayers.Size(20,34);
                    var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
                    var icon = new 
OpenLayers.Icon('http://boston.openguides.org/markers/RED.png',size,offset);

                    var geocoder = new GClientGeocoder();
                    if (geocoder) {
                        geocoder.getLatLng(
                        address,
                        function(point) {
                            if (!point) {
                                alert(address + " couldn't be found!");
                            } else {
                                var lonLat = new 
OpenLayers.LonLat(point.x,point.y).transform(new 
OpenLayers.Projection("EPSG:4326"),
                                new OpenLayers.Projection("EPSG:900913"));
                                map.setCenter(lonLat,7);

                    markers.clearMarkers();
                    markers.addMarker(new OpenLayers.Marker(lonLat, icon));
                                }
                                }
                                )
                            }
                    }

Hugo kirjoitti:
> Hello list,
>
> I have google geocoder inside my application and i would like to add a 
> temporary/on the fly point or png on the geocoded address. This is, 
> after entering an address, i have a setCenter to that adress but would 
> like to put just something calling the attention to those coordinates. 
> If i add new address, then this point would disapear and another point 
> would appear in the correct location.
> What do you advise me to use in this situation???
>
> Thanks for your help.
> Regards,
>
> Hugo
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>   



More information about the Users mailing list