Jump to content
php.lv forumi

Marķieru kosmiskas un komiskas pozīcijas Google Maps


Cibiņš

Recommended Posts

Sveicināti kolēģi! Šeit jau bez pamatojuma nelienu un nebļauju, bet nu, šoreiz kārtējā, laikam jau iesācēju, problēma :D

 

Man ir 3 faili, kuri veido google maps marķierus.

 

index.php

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://maps.google.com/maps?file=api&v=2" type="text/javascript"></script>

<script src="map_data.php" type="text/javascript"></script>
<script src="map_functions.js" type="text/javascript"></script>
</head>
<body>
<div id="map" style="width: 700px; height: 700px;"></div>
</body>
</html>

 

map_functions.js

 

var map;
   var centerLatitude = 37.818361;
   var centerLongitude = -122.478032;
   var startZoom = 13;

   function addMarker(longitude, latitude, description) {
       var marker = new GMarker(new GLatLng(latitude, longitude));
       GEvent.addListener(marker, 'click',
           function() {
  	         marker.openInfoWindowHtml(description);
           }
       );

       map.addOverlay(marker);
   }

   function init() {
       if (GBrowserIsCompatible()) {
           map = new GMap2(document.getElementById("map"));
           map.addControl(new GSmallMapControl());
           map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);
           for(id in markers) {
  	         addMarker(markers[id].latitude, markers[id].longitude, markers[id].name);
           }
       }
   }

   window.onload = init;
   window.onunload = GUnload;

 

un map_data.php

 


   var markers = [
       {
           'latitude': 37.818361,
           'longitude': -122.478032,
           'name': 'Zelta vārtu tilts'
       },
       {
           'latitude': 40.6897,
           'longitude': -74.0446,
           'name': 'Brīvības statuja'
       },
       {
           'latitude': 38.889166,
           'longitude': -77.035307,
           'name': 'Vašingtona monuments'
       }
   ];

 

Piesaistot map_data.php un map_functions.php pie index.php rodas kosmisks rezultāts - šie objekti atrodas kaut kur Antarktīdā. Vai tiešām pamazām notiek pasaules gals, ka šie objekti kaut kur pārvietojušies? :D Vai arī esmu kaut kur ielaidis kārtējo kļūdu..

Edited by Cibiņš
Link to comment
Share on other sites

Tu vienkārši padod parametrus nepareizā secībā. Apskaties addMarker definīciju

 

function addMarker(longitude, latitude, description) {

 

un kā tu padod datus

 

addMarker(markers[id].latitude, markers[id].longitude, markers[id].name);

 

redzi atšķirību?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...