2011 m. gegužės 30 d., pirmadienis

Google Maps: kaip vietoj GDirections pradžios ir pabaigos taškų įdėti savo paveiksliuką?

Sprendimas:
I did some research on how the real experts are doing it. They don't use the dir.load() function to draw the route. They draw it themselves.

I have added an example below of how they did it. I tested it this time and it is working.

Its unfortunate that the default icons can't be simply be replaced... Would have saved some people alot of time.

Anyway, hope it helps ^_^

var map;
google.load("maps", "2");
var dir;
var baseStartIcon;
var baseEndIcon;

function initialize(lat,lng)
{

//Initialize the Google maps
map = new google.maps.Map2(document.getElementById("mymap"));
map.setCenter(new google.maps.LatLng(0,0), 1,G_NORMAL_MAP);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());

//Create new icon objects
baseStartIcon = new GIcon();
baseEndIcon = new GIcon();

//Set the images of the icons
baseStartIcon.image = "smile.png";
baseEndIcon.image = "smile.png";

//Set the size of the image and the shadow (in pixels, this should be the same size as the images you are using)
baseStartIcon.iconSize = new GSize(16, 16);
baseEndIcon.iconSize = new GSize(16, 16);

//Set the anchor point of the new icon (x,y)
baseStartIcon.iconAnchor = new GPoint(8, 8); // this would be at the center of the icon
baseEndIcon.iconAnchor = new GPoint(8, 8); // this would be at the center of the icon

//create a new GDirections object with no options
dir = new GDirections();

//add a load event to the GDirection object
GEvent.addListener(dir,"load", function() {

//Get the poly line from the GDirections object
var poly=dir.getPolyline();

//moves the map to center the begining point in the user's view
//and sets the zoom level
map.setCenter(poly.getVertex(0),5);//poly.getVertex(0): is the first point of the polyline, the startpoint, 5: is the zoom level

//draw the polyline on the map
map.addOverlay(poly);

//Draw the custom icons
//one at the beginning
map.addOverlay(new GMarker(poly.getVertex(0),baseStartIcon));

//and one at the end of the polyline
map.addOverlay(new GMarker(poly.getVertex(poly.getVertexCount()-1),baseEndIcon));

});

dir.loadFromWaypoints(["San Francisco","Los Angeles"],{getPolyline:true});

}

google.setOnLoadCallback(initialize);


Pagal: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_24170806.html

Google Maps: kaip iš GDirection išmesti markerio ikonas A, B, C?

Problema: Can anyone help me creating a polyline for walking directions,
avoiding one-way streets?

Is it possible to disable the two green markers (A) and (B), from
directions? Keeping just the polyline?

Sprendimas
:

GEvent.addListener(directions, "addoverlay", function()
{
var nMarkers = directions.getNumGeocodes()
for(var i=0; i< nMarkers;i++)
{
var marker = directions.getMarker(i);
if (marker != null)
{ marker.hide();}
}
});

Pagal http://www.bottonisworld.com/2009/04/29/568/programmazione/js/come-modificare-i-marker-di-gdirections-delle-google-maps/

2011 m. gegužės 27 d., penktadienis

Google Maps: kaip keisti GDirections kelio spalvas, ikonas?

Kaip keisti GDirections kelio spalvas?

GPolyline doesn't support dots or dashes.

You can change things like the colour, width and opacity either like
this (using undocumented features):

GEvent.addListener(dirn,"load", function() {
var poly=dirn.getPolyline();
poly.color = "#FF0000";
poly.redraw(true)
});

Sprendimas: http://groups.google.com/group/google-maps-api/browse_thread/thread/a57a1191a950e118?pli=1

Kaip pakeisti GDirections ikonas?

http://groups.google.com/group/google-maps-api/browse_thread/thread/c67100eec0e58790/3b3833b69614c70f?lnk=gst&q=GDirections+custom+icons

2011 m. gegužės 25 d., trečiadienis

WordPress Error: Warning: Cannot modify header information

Problema: Warning: Cannot modify header information - headers already sent by (output started at /home/media/domains/pinkartav/trunk/wp-content/plugins/google-maps-route-plugin/php/nme-admin-map.php:2) in /home/media/domains/pinkartav/trunk/wp-includes/pluggable.php on line 897

Sprendimas aprašytas čia: http://www.hongkiat.com/blog/wordpress-error-warning-cannot-modify-header-information/

2011 m. gegužės 21 d., šeštadienis

Google maps nuorodos


http://www.blogger.com/img/blank.gif

Darbui su žemėlapiais:
http://code.google.com/intl/lt-LT/apis/maps/documentation/javascript/v2/services.html

Be to, "Google" tai nėra tik paieška ir žemėlapiai. Google Inc. yra sukūrusi nemažai nemokamų programų. Apie visa tai daugiau rasite čia: http://lukonetas.lt/google-tai-ne-tik-paieska/

Daug Google Maps pavyzdžių: http://googlemapsmania.blogspot.com/

2011 m. gegužės 4 d., trečiadienis

PHP: usort funkcija

Situacija: turėjau objektų masyvą, kuris buvo sudarytas jungiant kitus kelis masyvus. Masyvo struktūros pavyzdys:

Array
(
[0] => stdClass Object
(
[start_time] => 2010-10-14 18:00:00
[category_id] => 1
[tournament_id] => 41
[tournament_place] => Vilnius
[ratings] => 0.34
[place] => 145
[title] => Title 1
[photo] => http://myadress.lt/symbol2.jpg
)

[1] => stdClass Object
(
[start_time] => 2010-10-17 12:00:00
[category_id] => 1
[tournament_id] => 50
[tournament_place] => New York
[ratings] => 5.27
[place] => 30
[title] => Title 2
[photo] => http://myadress.lt/symbol.jpg
)

)


Reikėjo: surikiuoti galutinio masyvo elementus pagal datą mažėjimo tvarka (nuo didžiausio iki mažiausio).

Sprendimas: tam naudojama usort() funkcija, tačiau pagal nutylėjimą ji rikiuoja nuo mažiausio iki didžiausio.

function cmp($a, $b)
{
return ($a->tournament_id < $b->tournament_id) ? 1 : -1;
}

usort($result3,'cmp');

Jeigu į rikiavimą nereikėtų atsižvelgti, užtektų tokios funkcijos:

function cmp($a, $b)
{
return strcmp($a->tournament_id, $b->tournament_id);
}