konto usunięte

Temat: Różne kolory markera

Witam,
mam taką animację mapki:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">

<head>
<link rel="stylesheet" type="text/css" href="include.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>WebCAR: Historia</title>

<style type="text/css">

v\:* { behavior:url(#default#VML); }

body { font-family: Verdana, Sans-serif; }

h3 { margin-left: 8px; }

#map { height: 500px;
width: 650px;
border: 1px solid gray;
margin-top: 8px;
margin-left: 8px;
overflow: hidden;
}
.button { display: block;
width: 110px;
border: 1px Solid #565;
margin: 10px;
padding: 3px;
text-decoration: none;
text-align:center;
font-size:smaller;
}
.button:hover {
background-color: white;
}

#descr { position:absolute;
top:45px;
left: 680px;
width: 250px;
}

.infowindow { font-size: smaller;
text-align: left;
}

</style>


<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjqCDB3PN5y4xZCzYbKHOhBQpLwa5onnIYg2J2E2sqWBzh_6noBQ8Rsofj2RkT1eS7bLHxuqJggBBTA" type="text/javascript">

</script>

</head>

<body onload="buildMap()" onunload="GUnload()">

<h3> </h3>

<div id="map"> </div>


<div id="descr">
<a href="#" class="button" onclick="haltAnim();return false;"><img src="http://www.eksiegarnia.net/autka/icon_stop_d.gif" border="0"></a>
<a href="#" class="button" onclick="carryOn();return false;"><img src="http://www.eksiegarnia.net/autka/icon_next.gif" border="0"></a>

<a href="#" class="button" onclick="playAgain();return false;"><img src="http://www.eksiegarnia.net/autka/icon_play.gif" border="0"></a>
</div>


<script type="text/javascript">
//<![CDATA[

// Global variables
var data = [
{ name: "Puttgarden, Fehmarn", date: "7. Dezember", lat:"54.503143", lng:"11.229228" },
{ name: "Rødbyhavn", date: "7. Dezember", lat:"54.653278", lng:"11.349048" },
{ name: "Maribo", date: "8. Dezember", lat:"54.773563", lng:"11.491527" },
{ name: "Sakskøbing", date: "9. Dezember", lat:"54.796132", lng:"11.633834" },
{ name: "Vordingborg", date: "10. Dezember", lat:"55.011685", lng:"11.914844" },
{ name: "Rønnede", date: "10. Dezember", lat:"55.260729", lng:"12.021961" },
{ name: "Køge", date: "10. Dezember", lat:"55.461728", lng:"12.178688" },
{ name: "Kopenhagen",date: "11. Dezember",lat:"55.68", lng:"12.569999" },
{ name: "Hørsholm", date: "13. Dezember", lat:"55.884939", lng:"12.502098" },
{ name: "Helsingør", date: "14. Dezember", lat:"56.034458", lng:"12.614192" },
{ name: "Helsingborg", date: "16. Dezember", lat:"56.049992", lng:"12.697448" },
{ name: "Örkelljunga", date: "17. Dezember", lat:"56.289489", lng:"13.279724" },
{ name: "Hässleholm", date: "18. Dezember", lat:"56.167346", lng:"13.767242" },
{ name: "Kristianstad", date: "19. Dezember", lat:"56.020069", lng:"14.151077" },
{ name: "Ystad", date: "20. Dezember", lat:"55.429013", lng:"13.823547" },
{ name: "Rønne, Bornholm", date: "21. Dezember", lat:"55.099784", lng:"14.690437" },
{ name: "Saßnitz, Rügen", date: "22. Dezember", lat:"54.487591", lng:"13.581848" }

];

var map, route;
var points = [];
var gmarkers = [];
var count =0;
var stopClick = false;


function addIcon(icon) { // Add icon attributes

icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(32, 32);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(15, 34);
icon.infoWindowAnchor = new GPoint(19, 2);
icon.infoShadowAnchor = new GPoint(18, 25);
}


function addClickevent(marker) { // Add a click listener to the markers

GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(marker.content);
});
return marker;
}


function buildMap() {

if(GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(52.53627304145948, 19.05029296875), 15);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

// Light blue marker icons
var icon = new GIcon();
icon.image = "http://www.google.com/intl/en_de/mapfiles/ms/icons/ltblue-dot.png";
addIcon(icon);

for(var i = 0; i < data.length; i++) {
points[i] = new GLatLng(parseFloat(data[i].lat), parseFloat(data[i].lng));
gmarkers[i] = new GMarker(points[i], icon);

// Store data attributes as property of gmarkers
var html ="<div class='infowindow'>" +
"<strong>"+ data[i].name + "<\/strong><p>" +
data[i].date + "<\/p><\/div>";
gmarkers[i].content = html;
addClickevent(gmarkers[i]);
map.addOverlay(gmarkers[i]);
}
// Draw polylines between marker points
var poly= new GPolyline(points, "#003355", 3, .5);
map.addOverlay(poly);

// Open infowindow of first marker
gmarkers[0].openInfoWindowHtml( gmarkers[0].content);

route =setTimeout("anim()", 4200);
}
}


function haltAnim() {

if(route) {
clearTimeout(route);
stopClick = true;
}
}


function carryOn() {

if(stopClick == true) anim();
stopClick = false;
}


function anim() {

count++;
if(count < points.length) {
map.panTo(points[count]);
gmarkers[count].openInfoWindowHtml( gmarkers[count].content);
var delay = 3400;
if((count+1) != points.length)
var dist = points[count].distanceFrom(points[count+1]);

// Adjust delay
if( dist < 10000 ) {
delay = 2000;
}
if( dist > 80000 ) {
delay = 4200;
}
route = setTimeout("anim()", delay);
}
else {
clearTimeout(route);
count = 0;
route = null;
}
}


function playAgain() {

GUnload();
if(route) clearTimeout(route);
stopClick = false;
count = 0;
buildMap();
}

//]]>
</script>



wszystko działa oki - chciałbym tylko żeby market przy którym jest animacja (który ma aktualnie wyświetloną "chmurkę" był np. czerwony - zamiast niebieskiego) - wiecie może jak to zrobic??

Opierałem się na tym przykładzie: http://wolfpil.googlepages.com/anim.html


Z góry dzięki za pomoc,
pozdrawiam Łukasz
Marcin Laber

Marcin Laber internet
technologies
magician

Temat: Różne kolory markera

Po pierwsze - od jakiegoś już czasu na GL dostępny jest znacznik bbcode o nazwie code.
Po drugie:

function anim() {
count++;
if(count < points.length) {
map.panTo(points[count]);
gmarkers[count].openInfoWindowHtml( gmarkers[count].content);

//---
Aktualny marker masz w gmarkers[count] - możesz z nim robić co tam chcesz, włącznie ze zmianą ikony.
//---

var delay = 3400;
if((count+1) != points.length)
var dist = points[count].distanceFrom(points[count+1]);
// Adjust delay
if( dist < 10000 ) {
delay = 2000;
}
if( dist > 80000 ) {
delay = 4200;
}
route = setTimeout("anim()", delay);
}
else {
clearTimeout(route);
count = 0;
route = null;
}
}
Marcin Laber edytował(a) ten post dnia 12.09.08 o godzinie 14:21

konto usunięte

Temat: Różne kolory markera

dzięki:)))

konto usunięte

Temat: Różne kolory markera

coś jest jednak nie tak...:/
mam taki kod:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">

<head>
<link rel="stylesheet" type="text/css" href="include.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>WebCAR: Historia</title>

<style type="text/css">

v\:* { behavior:url(#default#VML); }

body { font-family: Verdana, Sans-serif; }

h3 { margin-left: 8px; }

#map { height: 500px;
width: 650px;
border: 1px solid gray;
margin-top: 8px;
margin-left: 8px;
overflow: hidden;
}
.button { display: block;
width: 110px;
border: 1px Solid #565;
margin: 10px;
padding: 3px;
text-decoration: none;
text-align:center;
font-size:smaller;
}
.button:hover {
background-color: white;
}

#descr { position:absolute;
top:45px;
left: 680px;
width: 250px;
}

.infowindow { font-size: smaller;
text-align: left;
}

</style>


<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjqCDB3PN5y4xZCzYbKHOhBQpLwa5onnIYg2J2E2sqWBzh_6noBQ8Rsofj2RkT1eS7bLHxuqJggBBTA" type="text/javascript">

</script>

</head>

<body onload="buildMap()" onunload="GUnload()">

<h3> </h3>

<div id="map"> </div>


<div id="descr">
<a href="#" class="button" onclick="haltAnim();return false;"><img src="http://www.eksiegarnia.net/autka/icon_stop_d.gif" border="0"></a>
<a href="#" class="button" onclick="carryOn();return false;"><img src="http://www.eksiegarnia.net/autka/icon_next.gif" border="0"></a>

<a href="#" class="button" onclick="playAgain();return false;"><img src="http://www.eksiegarnia.net/autka/icon_play.gif" border="0"></a>
</div>


<script type="text/javascript">
//<![CDATA[

// Global variables
var data = [
{ name: "ul. 3 Maja, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.5617", lng:"18.4063" },
{ name: "ul. Generała Henryka Dąbrowskiego, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.566", lng:"18.4039" },
{ name: "ul. powiat: ", date: "7. Dezember", lat:"54.566", lng:"18.4036" },
{ name: "ul. Szczecińska, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.5672", lng:"18.4007" },
{ name: "ul. Generała Władysława Andersa, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.5677", lng:"18.4009" },
{ name: "ul. Marynarska, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.568", lng:"18.4005" },
{ name: "ul. Warszawska, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.5693", lng:"18.4021" },
{ name: "ul. Poznańska, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.5692", lng:"18.4033" },
{ name: "ul. marszałka Józefa Piłsudskiego, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.5688", lng:"18.4001" },
{ name: "ul. marszałka Józefa Piłsudskiego, Rumia, Polska powiat: Wejherowski", date: "7. Dezember", lat:"54.5688", lng:"18.3997" },
];

var map, route;
var points = [];
var gmarkers = [];
var count =0;
var stopClick = false;


function addIcon(icon) { // Add icon attributes

icon.shadow = "http://www.google.com/mapfiles/shadow50.png";
icon.iconSize = new GSize(32, 32);
icon.shadowSize = new GSize(37, 34);
icon.iconAnchor = new GPoint(15, 34);
icon.infoWindowAnchor = new GPoint(19, 2);
icon.infoShadowAnchor = new GPoint(18, 25);
}


function addClickevent(marker) { // Add a click listener to the markers

GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(marker.content);
});
return marker;
}


function buildMap() {

if(GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(52.53627304145948, 19.05029296875), 15);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

// Light blue marker icons
var icon = new GIcon();
icon.image = "http://www.eksiegarnia.net/autka/punkt.png";
addIcon(icon);

for(var i = 0; i < data.length; i++) {
points[i] = new GLatLng(parseFloat(data[i].lat), parseFloat(data[i].lng));
gmarkers[i] = new GMarker(points[i], icon);

// Store data attributes as property of gmarkers
var html ="<div class='infowindow'>" +
"<strong>"+ data[i].name + "<\/strong><p>" +
data[i].date + "<\/p><\/div>";
gmarkers[i].content = html;
addClickevent(gmarkers[i]);
map.addOverlay(gmarkers[i]);
}
// Draw polylines between marker points
var poly= new GPolyline(points, "#003355", 3, .5);
map.addOverlay(poly);

// Open infowindow of first marker
gmarkers[0].openInfoWindowHtml( gmarkers[0].content);

route =setTimeout("anim()", 4200);
}
}


function haltAnim() {

if(route) {
clearTimeout(route);
stopClick = true;
}
}


function carryOn() {

if(stopClick == true) anim();
stopClick = false;
}


function anim() {

count++;

if(count < points.length) {

map.panTo(points[count]);
gmarkers[count].setImage('http://www.eksiegarnia.net/autka/obrazek.php?b=10&a=$autko&c=100');
gmarkers[count].openInfoWindowHtml( gmarkers[count].content);







var delay = 3400;

if((count+1) != points.length)

var dist = points[count].distanceFrom(points[count+1]);

// Adjust delay

if( dist < 10000 ) {

delay = 2000;

}

if( dist > 80000 ) {

delay = 4200;

}

route = setTimeout(function () { gmarkers[count].setImage('http://www.eksiegarnia.net/autka/punkt.png'); anim(); }, delay);

}

else {

clearTimeout(route);

count = 0;

route = null;

}

}




function playAgain() {

GUnload();
if(route) clearTimeout(route);
stopClick = false;
count = 0;
buildMap();
}

//]]>
</script>


</body>
</html>


i to mi zwraca błąd w IE:
zwraca 'data[...].lat' jest pusty lub nie jest obiektem:(

wiecie co może jest nie tak??
IE pisze że błąd jest w wierszu 131, znak 4 - czyli wychodzi na to że w: points[i] = new GLatLng(parseFloat(data[i].lat), parseFloat(data[i].lng));Łukasz Peta edytował(a) ten post dnia 12.09.08 o godzinie 22:28

konto usunięte

Temat: Różne kolory markera

Witam

Przecinek za końcowym elementem tablicy [data].Marcin K. edytował(a) ten post dnia 29.09.08 o godzinie 12:44



Wyślij zaproszenie do