[SOLVED] Google maps createMarker()

This is a discussion on "[SOLVED] Google maps createMarker()" within the JavaScript Forum section. This forum, and the thread "[SOLVED] Google maps createMarker() are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 8th, 2007, 16:06
Junior Member
Join Date: Sep 2007
Location: UK
Age: 37
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Google maps createMarker()

Hi I am trying to place a marker on my embedded google map.....but as my knowledge of javascript is minimal I am struggling!!!!!

Here is the code I have in my <header> tag
HTML: Select all
<linkhref=StyleSheet.csstype="text/css"rel=Stylesheet/>
<metahttp-equiv="content-type"content="text/html; charset=utf-8"/>
<title>How to find us</title>
<scriptsrc="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAApI7YGn0MV7bA ZkIUezyLkxQg3LUq9t7qqiUlwmhNYuCv0JzBnxT2P6Ib2Drqux 3jiO6q5QDBfG7Y9Q"
type="text/javascript"></script>
<scripttype="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(53.4227, -2.9509), 15);
//code to try and place marker
function createMarker(point, html)
{
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function()
{
marker.openInfoWindowHtml(html);
});
return marker;
}
var point = new GLatLang(53.4227, -2.9509);
createMaker(point, 'We are here!');
map.addOverlay(marker);
}

}

//]]>
</script>
and in the body it just calls the onload() function....
the map is being displayed but not the marker.....any help as to where I am going wrong???

Last edited by Rakuli; Oct 9th, 2007 at 05:47. Reason: Please use [html][/html] tags when posting code.
Reply With Quote

  #2 (permalink)  
Old Oct 9th, 2007, 01:14
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Google maps createMarker()

I suggest you use something else, entirely!

If you are using Dreamweaver, check this out (it's 100% free):
Tools for Google

This is a small extension for Dreamweaver that allows you to quickly insert maps and other things from Google into your web page.

If you are not using Dreamweaver, tell me what you're using. I might be able to help, anyway.

Cheers,
SWagner
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #3 (permalink)  
Old Oct 9th, 2007, 09:54
Junior Member
Join Date: Sep 2007
Location: UK
Age: 37
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Google maps createMarker()

Hello
I am using Visual Web Developer....
I think I am getting there slowly but surely with javascript....
I have this code so far that loads the map but not the marker

function load()
{
var point = new GLatLng(53.4227, -2.9509)

if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map"));
map.setCenter(point, 13);
createMarker(point,
'We are here!');
map.addOverlay(marker);
}

function createMarker(point, html)
{
var marker = new GMarker(point);
GEvent.addListener(marker,
"click", function()
{
marker.openInfoWindowHtml(html);
});
return marker;
}
}

The page is loading but with errors on page....I seems to be failing on the line
createMarker(point, 'We are here!');

any ideas what Ive done wrong???
Reply With Quote
  #4 (permalink)  
Old Oct 10th, 2007, 00:19
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Google maps createMarker()

OK. First of all, where did you get this code? Usually a code is "handed out" with some sort of explanation...
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
  #5 (permalink)  
Old Oct 10th, 2007, 09:41
Junior Member
Join Date: Sep 2007
Location: UK
Age: 37
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Google maps createMarker()

Its OK problem solved.......I wasnt creating an instance of the object 'marker'.....the one inside the function createMarker was outside the scope of the main function. I just needed to add
var marker = createMarker(point, 'We are here!');
when calling the function.
The code by the way was courtesy of google maps api.
I just adapted it a bit
Reply With Quote
  #6 (permalink)  
Old Oct 10th, 2007, 11:56
Highly Reputable Member
Join Date: Sep 2007
Age: 15
Posts: 717
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Re: [SOLVED] Google maps createMarker()

OK. Sounds great. The variable call sometimes throws people off . I have used Google codes before, and I was sure that it wasn't a big deal.

Regards,
SWagner
Last Blog Entry: Windows Vista vs. Mac Leopard (Nov 4th, 2007)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
google maps pas2gether ASP.NET Forum 4 Oct 27th, 2007 06:41
Google Maps Question uqwebdesign Web Page Design 2 May 14th, 2007 16:53
Google Maps Question uqwebdesign Web Page Design 2 Feb 17th, 2007 08:02
Using Google Maps? blizeH Webforumz Cafe 12 Dec 21st, 2006 15:30
Google Maps... craig Webforumz Cafe 1 Nov 27th, 2006 16:37


All times are GMT. The time now is 10:07.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43