SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Google Maps setCenter

    Is there a function to calculate center of the map when displaying multiple markers? I can't seem to find one, I got the markers showing up but they are always off-map and I have to scroll to see them on the actual map.

    Thanks for your help.

  2. #2
    SitePoint Addict dbr's Avatar
    Join Date
    Aug 2006
    Location
    Tucked away in the mountains...
    Posts
    228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    I custom wrote mine, but here are the key pieces:

    PHP Code:
    $mapcenterLat = ($smallestLat $largestLat)/2;
    $mapcenterLon = ($smallestLon $largestLon)/2
    Code:
    map.setCenter(new GLatLng(<?php echo $mapcenterLat; ?>,<?php echo $mapcenterLon; ?>), <?php echo $zoomfactor; ?> );
    I calculate the distance between the smallest and largest to adjust my zoom factor to show all markers on the map.

    To see a nice tight sample use:
    36.28 -92.32
    for a Cast Initiation Point and select
    gasoline
    for a category. Then after doing the ProximityCast click the MAP VIEW button at the top right of the castnet page.

    Hope this helps.
    "Three components make an entrepreneur:
    the person, the idea, and the resources to make it happen."
    Anita Roddick ~British entrepreneur
    dbr founder of: ProximityCast.com

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That helped a lot, thanks!

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Location
    Houston, TX
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you obtain the value for $zoomfactor?

    Thanks!


Bookmarks

Posting Permissions

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