Google Maps Api V3 - Add Markers From A Xml File To Map
Jul 8, 2010
I have some trouble with the google maps api. I want to add markers from a xml file to my map but it seems that the function is not parsing my xml file and I am clueless.
i have a page with an input field where a user can input a name. when they do so it will bring back the postcode for that name and then display a marker on a google map in the correct place.
unfortunately some of the names have more than 1 result which means it needs to plot more than 1 marker on the map...ive spent a lot of time on this but cant figure it out.
I have an array of latitude/longitude data. I need to make a marker appear on the map for each lat/lng pair. But it won't. If I ask the function to print out the coordinates instead of marking them on the, map, it works fine. I don't get an error message either way, so I'm stuck. The page displays the map but without any markers. Here's the code of the function that should add markers:
//adds markers to the map function addMarkers(locarray) { var infowindow = new google.maps.InfoWindow(); var marker, i; for (i = 0; i < locarray.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locarray[i][0], locarray[i][1]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent('some words'); infowindow.open(map, marker); }})(marker, i)); }}
Here's the initialize function (called on body load): function initialize() { geocoder = new google.maps.Geocoder(); var latlng = codeAddress("<?php echo $_POST['postal']; ?>"); var myOptions = { zoom: 11, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); }
Geocoder and map are declared as global variables. The codeAddress function returns lat and lng of the place I want to center the map around, it's been tested and works perfectly. And here is the script that declares the array and calls the addMarkers function: <script type='text/javascript'> var locations = [ [-33.890542, 151.274856], [-33.923036, 151.259052], [-34.028249, 151.157507], ]; addMarkers(locations) </script>
MY GOAL - I have a database with a bunch of items and each has latitude, longitude and a category (all the items are within 1 city). I want to have a page that will show a google map, display a marker based on the lat/lng and the image of the marker should be customized based on the category of the row. For example, some rows have a 'food' category and some have a 'health' category - I have specific images I want displayed for each image. I need a script that will plot a marker for each item in my db. I have never used Google maps API before and I'm thinking V3 is what I need to use.
$query=mysql_query("SELECT * FROM table"); while($row=mysql_fetch_array($query)){ $lat=$row['lat']; $lng=$row['lng']; $category=$row['category']; //SET MARKER PICTURE TO $category //ADD MARKER TO MAP } I don't know javascript that well and I have tried about 40 different things and get nothing but a blank page!
I've got a few locations that I'd like to put on a google map and can do it just fine when I use the following code:[code]However, when I try to do it via an array the markers appear, but not in the correct location and I can't figure out why.Below is my version where I attempt to use an array:[code]
1. In the current script, the markers are set to be random within a radius. What would be an easy way to switch from that to using individual markers that I set from latitudes and longitudes? I'm going to be using around 5 way points surrounding an area and can either hard code or throw in some PHP code.
2. In addition to setting my markers, the navigation is done through generated links like "Point 1", "Point 2", and so forth. How would I insert code to replace .html("Point "+i) with something else? I'm guessing to have a main city, have a few towns around it, and the "Point" links are replaced with text I want to use. Probably hard code or use PHP/MySQL to show a zip code or town related to that marker.Here is a sample of the JavaScript code. I only threw in PHP echo tags for the start lat/long and I have that set:
Code: $(document).ready(function(){ var map = new GMap2($("#map").get(0)); var StartArea = new GLatLng(<?=$latitude?>,<?=$longitude?>);[code].........
I pulled this code from Google's example section to make markers on a v3 Google Maps API (I have added my own lat/long points and corresponding event listeners, of course, but this is still the spirit of the code):
[Code]...
It's not throwing up any errors in Firefox's developer or in IE but there it sits, a blank map. I'm sure this isn't clean or optimized code, but it looks correct to me. I've color-coded the code above to show what "for" loops are being used to try to replace which code. Hopefully that makes this more sensible.
I want to have several maps on my aspx/ascx-Webpage, but only the last one is rendered after PageLoad(). Is there any limitation for that in the goMap() plugin?
I have a php page that pulls MySQL marker locations.I have tried using examples for bounds etc but the map isn't centered or zoomed, it instead seems to center over the Pacific and minimum zoom level (For the url below it should be centered over the Devon region of the UK and zoomed in)the page where you can see the end result is here:
http:[url].......... whereby I was using deprecated function of GPoint for passing locations but one of the group mods kindly pointed this out and this was replaced with GLatLng but the fault is still there.
I was using a google map V2 API, but decided as it is deprectaed, to step up and use the latest version, and it is doing my head in. Basically all I want is a map, that has 5 checkboxes, checkbox1, checkbox2 etc... and if one or all is checked then a marker will appear on the map that I have location preset, the marker when clicked will show a little information and contain a url. I was able to get the map with the five markers completed using V2, but when I was researching how to use checkboxes, i kept being led to the V3 API. I think the Google documentation is pretty bad for this PAI, as there is tons and tons of information but none of it is explaing the simple things, like how to set mutilple markers in V3. It will instead show you how to create polygons using images and fancy stuff that is not essential.
I'm developing a land use map and want to use Google Maps. Just want to ask if the Javascript API could actually handle overlays like this sample: URl...Or you would suggest other ways to do this?
I'm not sure where I have translated this incorrectly. I have one google map embedded on my page which works fine. But I wanted to add a second one. I thought the easiest way to do this would be to have a second page which is called later on with all the details on it for the second map. However although I think (this I presume is where I went wrong) I have replicated the instructions correctly the place holder for the second map just remains blank.
This is the code for my called page with the instructions for the second map:
And this is the script of the main page, just in case I would be better off keeping them both in one place.
<head>
I've cut out the script that doesn't relate to this so I hope I haven't missed anything important.
I'm working on a project which implements google Maps. Now I have to choose between GWT or JavaScript as a programming platform. I'm wondering which is faster when accessing the data to be used to initialise the maps from a remote server?
Been looking at google maps, but i am not sure if this is possible, what do you think?
1) Fill database with places (refering to lat + long values) + put markers on google map. 2) Users can then browse the map, click on a marker to select the location which referes to a place in a database.
I know I can add markers to a map. Not sure if it is possible for a user to click one, which then fills a box in a form though.
I am working on creating a map using the google maps API. I would like to update the markers and info windows using an XML database. I know how to parse the XML using PHP if I was just going to create a table on the page, but for the life of me I can't find a complete and simple description of how to do it with javascript. I've been reading tutorials and W3 schools reference for over a week trying to figure it out. I'm new to javascipt, so some of the stuff I don't really understand. I did find a similar question posted on this forum, although I can't get it working. Here is my code (note: this code doesn't work, I know that I'm missing some way to load the xml and parse it, but I don't see how its done):
We got a google maps with a bunch of pins. Each pin is setup to use our blue custom icon image. I'm trying to make it so that when you click on a pin, that particular pin changes to a green version of the icon, and all the reset stay blue. If the user clicks another pin, it turns green and the previous goes back to blue.Basicly only the clicked active pin should be green.
Here is my code so far that will change the clicked pin into a green version.My problem is all attempts to change all pins back to blue prior to changing this clicked pin to green fails bad.
I am messing around with Google Maps a little and the fundamental difficulty in building anything useful is extrapolating address information from another website. I would like to be able to use a form like yahoo yellow pages send it a zip code and get back a bunch of, say, banks in that zip code and parse the address out. Some things, very few, actually return data in the XML format, but how do you write a script that send a request to a website and then returns that request as a DOM object. I'll even take HTML and then I'll parse it out myself, but how do you do that.
I know it sounds fundamental, but I'm a real beginner in this, so if you can push me in the right direction I would appreciate it too.
I've seen several websites using a custom image as a map with google maps controls.I'm familiar with how to use the google maps api in general, but I don't know how to use a custom map image that isn't based on the real world, in other words it will be an image of a map from a video game, so general latitude and longitude wont apply.
I am trying to display a map with Google maps. The code listed below is located at http:[url]....
Code: <!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" xml:lang="en" lang="en">[code]....
I find another example where some uses a CDATA tag, but it still doesn't work. http:[url]...I finally remove the DOCTYPE and it works. http:[url]....My problem is I want the DOCTYPE.