Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
use createMarker to drop marker from top of map
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  11 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
JWoodall  
View profile  
 More options Nov 7, 4:21 am
From: JWoodall <woodal...@gmail.com>
Date: Fri, 6 Nov 2009 09:21:11 -0800 (PST)
Local: Sat, Nov 7 2009 4:21 am
Subject: use createMarker to drop marker from top of map
I have a map that will contain 50 or so markers and as the markers are
created, I was wondering if it was possible to drop them vertically
from the top of the map down to their correct longitude... making the
map somewhat animated.  Has anyone done this before?

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcelo  
View profile  
 More options Nov 7, 5:44 am
From: Marcelo <marcelo...@hotmail.com>
Date: Fri, 6 Nov 2009 10:44:35 -0800 (PST)
Local: Sat, Nov 7 2009 5:44 am
Subject: Re: use createMarker to drop marker from top of map
On Nov 6, 6:21 pm, JWoodall <woodal...@gmail.com> wrote:

> I have a map that will contain 50 or so markers and as the markers are
> created, I was wondering if it was possible to drop them vertically
> from the top of the map down to their correct longitude... making the
> map somewhat animated.

Easy!
- Create the marker at the longitude the user defined and the latitude
of the top of the map.
map.getBounds().getNorthEast().lat()
- Then animate it with afunction like

// Pseudo-code
function moveMarker() {
  var p1 = map.fromLatLngToDivPixel(marker.getLatLng());
  var p2 = map.fromLatLngToDivPixel(userSelectedLatLng);
  var deltaPixels = Math.abs(p2.y - p1.y);
  var step = Math.floor(deltaPixels/ 10);
  var newLatLng = map.fromDivPixelToLatLng(new GPoint(p1.x,p1.y
+step));
  marker.setLatLng(newLatLng)

}

Has anyone done this before?

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcelo  
View profile  
 More options Nov 7, 5:48 am
From: Marcelo <marcelo...@hotmail.com>
Date: Fri, 6 Nov 2009 10:48:32 -0800 (PST)
Local: Sat, Nov 7 2009 5:48 am
Subject: Re: use createMarker to drop marker from top of map
On Nov 6, 7:44 pm, Marcelo <marcelo...@hotmail.com> wrote:

> On Nov 6, 6:21 pm, JWoodall <woodal...@gmail.com> wrote:

> > I have a map that will contain 50 or so markers and as the markers are
> > created, I was wondering if it was possible to drop them vertically
> > from the top of the map down to their correct longitude... making the
> > map somewhat animated.

Sorry. Previous post went off too early. (I thought I was using my
editor and pushed the wrong keys) :-)

// Pseudo-code - Untested
function moveMarker() {
  var p1 = map.fromLatLngToDivPixel(marker.getLatLng());
  var p2 = map.fromLatLngToDivPixel(userSelectedLatLng);
  var deltaPixels = Math.abs(p2.y - p1.y);
  var step = Math.floor(deltaPixels/ 10);
  var newLatLng = map.fromDivPixelToLatLng(new GPoint(p1.x,p1.y
+step));
  marker.setLatLng(newLatLng)

  if (deltaPixels - step > step) {
    window.setTimeout("moveMarker()",200);
  }

}

> Has anyone done this before?

Does it matter? Be the first! :-)

--
Marcelo - http://maps.forum.nu
--


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JWoodall  
View profile  
 More options Nov 7, 6:09 am
From: JWoodall <woodal...@gmail.com>
Date: Fri, 6 Nov 2009 11:09:10 -0800 (PST)
Local: Sat, Nov 7 2009 6:09 am
Subject: Re: use createMarker to drop marker from top of map
Thanks for the quick response.  Where/when would I call the
function...? my markers are generated from an xml file that has there
Lat/Long and some info for the infoWindow.

                function createMarker(point, iconname, info) {
                        var icon = new GIcon(baseIcon);
                        icon.image = iconname.getAttribute("image");
                        var marker = new GMarker(point, icon);

                        GEvent.addListener(marker, "click", function() {
                                marker.openInfoWindowHtml("stuff from xml");
                        });

                        moveMarker(marker);
                        return marker;
                }

                function moveMarker(marker) {
                        var p1 = map.fromLatLngToDivPixel(marker.getLatLng());
                        var p2 = map.fromLatLngToDivPixel(userSelectedLatLng);
                        var deltaPixels = Math.abs(p2.y - p1.y);
                        var step = Math.floor(deltaPixels/ 10);
                        var newLatLng = map.fromDivPixelToLatLng(new GPoint(p1.x,p1.y
                        +step));
                        marker.setLatLng(newLatLng)

                        if (deltaPixels - step > step) {
                                window.setTimeout("moveMarker()",200);
                          }

                }

On Nov 6, 1:48 pm, Marcelo <marcelo...@hotmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JWoodall  
View profile  
 More options Nov 7, 6:09 am
From: JWoodall <woodal...@gmail.com>
Date: Fri, 6 Nov 2009 11:09:18 -0800 (PST)
Local: Sat, Nov 7 2009 6:09 am
Subject: Re: use createMarker to drop marker from top of map
Thanks for the quick response.  Where/when would I call the
function...? my markers are generated from an xml file that has there
Lat/Long and some info for the infoWindow.

                function createMarker(point, iconname, info) {
                        var icon = new GIcon(baseIcon);
                        icon.image = iconname.getAttribute("image");
                        var marker = new GMarker(point, icon);

                        GEvent.addListener(marker, "click", function() {
                                marker.openInfoWindowHtml("stuff from xml");
                        });

                        moveMarker(marker);
                        return marker;
                }

                function moveMarker(marker) {
                        var p1 = map.fromLatLngToDivPixel(marker.getLatLng());
                        var p2 = map.fromLatLngToDivPixel(userSelectedLatLng);
                        var deltaPixels = Math.abs(p2.y - p1.y);
                        var step = Math.floor(deltaPixels/ 10);
                        var newLatLng = map.fromDivPixelToLatLng(new GPoint(p1.x,p1.y
                        +step));
                        marker.setLatLng(newLatLng)

                        if (deltaPixels - step > step) {
                                window.setTimeout("moveMarker()",200);
                          }

                }

On Nov 6, 1:48 pm, Marcelo <marcelo...@hotmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcelo  
View profile  
 More options Nov 7, 6:21 am
From: Marcelo <marcelo...@hotmail.com>
Date: Fri, 6 Nov 2009 11:21:03 -0800 (PST)
Local: Sat, Nov 7 2009 6:21 am
Subject: Re: use createMarker to drop marker from top of map
On Nov 6, 8:09 pm, JWoodall <woodal...@gmail.com> wrote:

> Thanks for the quick response.  Where/when would I call the
> function...?

I don't know, because I can't see your page.

--
Marcelo - http://maps.forum.nu
--


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JWoodall  
View profile  
 More options Nov 7, 6:51 am
From: JWoodall <woodal...@gmail.com>
Date: Fri, 6 Nov 2009 11:51:01 -0800 (PST)
Local: Sat, Nov 7 2009 6:51 am
Subject: Re: use createMarker to drop marker from top of map
Thanks for the quick response.  Where/when would I call the
function...? my markers are generated from an xml file that has there
Lat/Long and some info for the infoWindow.

                function createMarker(point, iconname, info) {
                        var icon = new GIcon(baseIcon);
                        icon.image = iconname.getAttribute("image");
                        var marker = new GMarker(point, icon);

                        GEvent.addListener(marker, "click", function() {
                                marker.openInfoWindowHtml("stuff from xml");
                        });

                        moveMarker(marker);
                        return marker;
                }

                function moveMarker(marker) {
                        var p1 = map.fromLatLngToDivPixel(marker.getLatLng());
                        var p2 = map.fromLatLngToDivPixel(userSelectedLatLng);
                        var deltaPixels = Math.abs(p2.y - p1.y);
                        var step = Math.floor(deltaPixels/ 10);
                        var newLatLng = map.fromDivPixelToLatLng(new GPoint(p1.x,p1.y
                        +step));
                        marker.setLatLng(newLatLng)

                        if (deltaPixels - step > step) {
                                window.setTimeout("moveMarker()",200);
                          }

                }

On Nov 6, 1:48 pm, Marcelo <marcelo...@hotmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JWoodall  
View profile  
 More options Nov 7, 6:53 am
From: JWoodall <woodal...@gmail.com>
Date: Fri, 6 Nov 2009 11:53:48 -0800 (PST)
Local: Sat, Nov 7 2009 6:53 am
Subject: Re: use createMarker to drop marker from top of map
Yeah, and it's inside a firewall or I would link to it.  Here's the
entire script.

        <script src="http://maps.google.com/maps?
file=api&v=1&key=ABQIAAAAwJZL6qmHRMoJ3eEFmNHeURQc7yXP-42arpddqVt4pIZac6lvOB S1WuGKvGY468_Hu2ulMqwfVN2WIQ"
type="text/javascript"></script>
        <script type="text/javascript">
                //<![CDATA[
        function load(){

                var map = new GMap(document.getElementById("map"));
                var point = new GPoint(-96.926791,32.863917);
                map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());
                map.centerAndZoom(point, 5);
                //map.setBounds(map.GBounds(-67.30, 18.611, -66.13, 17.786));
                var baseIcon = new GIcon();
                baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
                baseIcon.iconSize = new GSize(18, 50);
                baseIcon.shadowSize = new GSize(37, 34);
                baseIcon.iconAnchor = new GPoint(9, 34);
                baseIcon.infoWindowAnchor = new GPoint(9, 2);
                baseIcon.infoShadowAnchor = new GPoint(15, 15);

                var request = GXmlHttp.create();
                request.open("GET", "zips.xml", true);

                request.onreadystatechange = function() {
                        if (request.readyState == 4) {
                                        var xmlDoc = request.responseXML;

                                        var zips = xmlDoc.documentElement.getElementsByTagName("point");
                                        var icons = xmlDoc.documentElement.getElementsByTagName("icon");
                                        var info = xmlDoc.documentElement.getElementsByTagName("info");

                                        for (var i = 0; i < zips.length; i++) {
                                        var point = new GPoint(parseFloat(zips[i].getAttribute("lng")),
                                                                         parseFloat(zips[i].getAttribute("lat")));

                                        var marker = createMarker(point, icons[i], info[i]);
                                        map.addOverlay(marker);
                                        }
                        }
                }

                function createMarker(point, iconname, info) {
                        var icon = new GIcon(baseIcon);
                        icon.image = iconname.getAttribute("image");
                        var marker = new GMarker(point, icon);

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

                        return marker;
                }

                request.send(null);
        }

                //]]>
        </script>

On Nov 6, 2:21 pm, Marcelo <marcelo...@hotmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
JWoodall  
View profile  
 More options Nov 7, 6:53 am
From: JWoodall <woodal...@gmail.com>
Date: Fri, 6 Nov 2009 11:53:53 -0800 (PST)
Local: Sat, Nov 7 2009 6:53 am
Subject: Re: use createMarker to drop marker from top of map
Yeah, and it's inside a firewall or I would link to it.  Here's the
entire script.

        <script src="http://maps.google.com/maps?
file=api&v=1&key=ABQIAAAAwJZL6qmHRMoJ3eEFmNHeURQc7yXP-42arpddqVt4pIZac6lvOB S1WuGKvGY468_Hu2ulMqwfVN2WIQ"
type="text/javascript"></script>
        <script type="text/javascript">
                //<![CDATA[
        function load(){

                var map = new GMap(document.getElementById("map"));
                var point = new GPoint(-96.926791,32.863917);
                map.addControl(new GLargeMapControl());
                map.addControl(new GMapTypeControl());
                map.centerAndZoom(point, 5);
                //map.setBounds(map.GBounds(-67.30, 18.611, -66.13, 17.786));
                var baseIcon = new GIcon();
                baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
                baseIcon.iconSize = new GSize(18, 50);
                baseIcon.shadowSize = new GSize(37, 34);
                baseIcon.iconAnchor = new GPoint(9, 34);
                baseIcon.infoWindowAnchor = new GPoint(9, 2);
                baseIcon.infoShadowAnchor = new GPoint(15, 15);

                var request = GXmlHttp.create();
                request.open("GET", "zips.xml", true);

                request.onreadystatechange = function() {
                        if (request.readyState == 4) {
                                        var xmlDoc = request.responseXML;

                                        var zips = xmlDoc.documentElement.getElementsByTagName("point");
                                        var icons = xmlDoc.documentElement.getElementsByTagName("icon");
                                        var info = xmlDoc.documentElement.getElementsByTagName("info");

                                        for (var i = 0; i < zips.length; i++) {
                                        var point = new GPoint(parseFloat(zips[i].getAttribute("lng")),
                                                                         parseFloat(zips[i].getAttribute("lat")));

                                        var marker = createMarker(point, icons[i], info[i]);
                                        map.addOverlay(marker);
                                        }
                        }
                }

                function createMarker(point, iconname, info) {
                        var icon = new GIcon(baseIcon);
                        icon.image = iconname.getAttribute("image");
                        var marker = new GMarker(point, icon);

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

                        return marker;
                }

                request.send(null);
        }

                //]]>
        </script>

On Nov 6, 2:21 pm, Marcelo <marcelo...@hotmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marcelo  
View profile  
 More options Nov 7, 6:58 am
From: Marcelo <marcelo...@hotmail.com>
Date: Fri, 6 Nov 2009 11:58:08 -0800 (PST)
Local: Sat, Nov 7 2009 6:58 am
Subject: Re: use createMarker to drop marker from top of map
On Nov 6, 8:53 pm, JWoodall <woodal...@gmail.com> wrote:

> Yeah, and it's inside a firewall or I would link to it.  Here's the
> entire script.

No, thanks. I never read code dumps.

Please read and follow the group's posting guidelines:
http://groups.google.com/group/Google-Maps-API/web/suggested-posting-...
http://groups.google.com/group/Google-Maps-API/web/why-including-a-li...

--
Marcelo - http://maps.forum.nu
--


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Esa  
View profile  
 More options Nov 8, 1:43 am
From: Esa <esa.ilm...@gmail.com>
Date: Sat, 7 Nov 2009 06:43:59 -0800 (PST)
Local: Sun, Nov 8 2009 1:43 am
Subject: Re: use createMarker to drop marker from top of map
    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google