[Google Maps API v2] help with google maps api
The following is a script that does geocoding, you can input a city and street and it will look for it. I just need a simple script that can search within positions in the kml file, lets say you input some city and street and if it is as a marker or polyline in the kml file (as a name basically) then screen centers on it. Just that simple script would be welcome. Or you can tell me how to transform this one:
<body onload="mapaStart()">
<script type="text/javascript">
<!--
var mapa;
var dymek;
var geokoder = new google.maps.Geocoder();
var rozmiar = new google.maps.Size(32,32);
var rozmiar_cien = new google.maps.Size(59,32);
var punkt_startowy = new google.maps.Point(0,0);
var punkt_zaczepienia = new google.maps.Point(16,16);
var ikona = new google.maps.MarkerImage("http://maps.google.com/mapfiles/kml/pal3/icon52.png", rozmiar, punkt_startowy, punkt_zaczepienia);
var cien = new google.maps.MarkerImage("http://maps.google.com/mapfiles/kml/pal3/icon52s.png", rozmiar_cien, punkt_startowy, punkt_zaczepienia);
var wskaznik = new google.maps.Marker({icon: ikona, shadow: cien});
function mapaStart()
{
var wspolrzedne = new google.maps.LatLng(37.7671, -122.4206);
var opcjeMapy = {
zoom: 15,
center: wspolrzedne,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true
};
mapa = new google.maps.Map(document.getElementById("mapka"), opcjeMapy);
dymek = new google.maps.InfoWindow();
geokoder.geocode({address: 'Szczecin, Krzywoustego 23'}, obslugaGeokodowania);
var ctaLayer = new google.maps.KmlLayer({ url: 'http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml'});
ctaLayer.setMap(mapa);
//poniżej marker/tag
var punkt = new google.maps.LatLng(53.400,14.400); // definiujemy punkt o współrzędnych 53.400,14.400
var opcjeMarkera =
{
position: punkt,
map: mapa,
title: 'Pierwszy marker!'
}
var marker = new google.maps.Marker(opcjeMarkera);
}
function skoczDoAdresu(adres)
{
wskaznik.setMap(null);
geokoder.geocode({address: adres}, function(wyniki, status)
{
if(status == google.maps.GeocoderStatus.OK)
{
mapa.setCenter(wyniki[0].geometry.location);
wskaznik.setPosition(wyniki[0].geometry.location);
wskaznik.setMap(mapa);
dymek.open(mapa, wskaznik);
dymek.setContent('<strong>Poszukiwany adres</strong><br />'+adres);
}
else
{
alert("Nie znalazłem podanego adresu!");
}
});
}
function obslugaGeokodowania(wyniki, status)
{
}
function skoczdotaga(tag)
{
wskaznik.SetMap(null);
if(status == google.maps.GeocoderStatus.OK)
{
mapa.setCenter(wyniki[0].geometry.location);
wskaznik.setPosition(wyniki[0].geometry.location);
wskaznik.setMap(mapa);
dymek.open(mapa, wskaznik);
dymek.setContent('<strong>Poszukiwany adres</strong><br />'+adres);
}
else
{
alert("Brak planów instalacji w tym rejonie");
}
}
-->
</script>
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-maps-api+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home