Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2007
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript and PHP and Google maps

    Hello,

    I'm trying to dynamically generate markers on a google map. I have a php object that holds the coordinates for a few locations.

    This is my javascript function that is called when the page is loaded


    Code:
    function load() {
    			if (GBrowserIsCompatible()) {
    				//Create the map object
    				var map = new GMap2(document.getElementById("mashup"));
    				//add the zoom and pan control
    				map.addControl(new GLargeMapControl());
    				//center the map
    				map.setCenter(new GLatLng(51.535, -0.1214), 12);
    				
    				//Create the basic icon
    				var baseIcon = new GIcon();
    				baseIcon.shadow = "/support/img/myspoonfed/googleShadow.png";
    				baseIcon.image = "/support/img/myspoonfed/googleType2.png";
    				baseIcon.iconSize = new GSize(20, 44);
    				baseIcon.shadowSize = new GSize(55, 40);
    				baseIcon.iconAnchor = new GPoint(9, 44);
    				baseIcon.infoWindowAnchor = new GPoint(9, 2);
    				baseIcon.infoShadowAnchor = new GPoint(18, 25);
    				baseIcon.infoShadowAnchor = new GPoint(18, 25);
    				
    				//loop through the list of events and generate markers
    				<?php foreach ($obj->all as $key => $value) {?>
    					var point = new GLatLng(<?= $value["location_latitude"]?>,<?= $value["location_longitude"]?>);
                                             var marker = new GMarker(point, baseIcon);
    				
    				          GEvent.addListener (marker, "click", function () {
    					           marker.openInfoWindowHtml(desc);
    				             });
    				
    				           map.addOverlay(marker);
    
    				<?php } ?>
    				
    				
    			}
    		}
    Why doesn't this work?

    Many thanks.

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    can you be more specific than 'it doesnt work?'

    Have you checked that your co-ordinates are the right way around?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •