0

それらの場所の住所と写真でいっぱいのデータベースがあります。注:緯度/経度はありません。

私は何をする必要がありますか:

Google API v3 を使用してこれらの住所のいくつかを Google マップにリストする関数を作成します。マーカーをクリックすると、住所とデータベースからの画像が表示されます。これはページのプラグインなので、ヘッダー データを編集できません。表示されている場所にのみコードを挿入できます。

私はすでにドキュメントを読んでいますが、私のジオマップが必要としない多くの不要なコードやものがすべてにあるようです。必要に応じて後で追加できるように、可能な限り簡単な解決策を探しています。

4

4 に答える 4

1

ここで作成した地図の赤いマーカーをクリックしてください: http://www.dougglover.com/samples/UOITMap/index.html

それはあなたが探しているものですか?

于 2010-05-05T13:39:47.907 に答える
1
    Here is the full html with google map api v3, markers will be create on dragging the route and then each marker having custom html inside the infowindow.

    <!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 type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript">
var rendererOptions = {
  draggable: true,
  suppressInfoWindows: true
  };
var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
var directionsService = new google.maps.DirectionsService();
var infowindow = new google.maps.InfoWindow();
var map;
var total;
var waypoint_markers = []

var myOptions = {
    zoom: 6,
    center: new google.maps.LatLng(46.87916, -3.32910),
    mapTypeId: 'terrain'
};
var markers = [];

function init() {
  map = new google.maps.Map(document.getElementById('map'),{'mapTypeId': google.maps.MapTypeId.ROADMAP});

  directionsDisplay.setMap(map);
  //directionsDisplay.setPanel($("#directionsPanel")[0]);

  google.maps.event.addListener(directionsDisplay, 'directions_changed', function() {
    watch_waypoints();
  });
  calcRoute(false);
}

function calcRoute(waypoints) {
  var selectedMode = "DRIVING"; //document.getElementById("mode").value;
  var ary;
  if(waypoints) {
    ary = waypoints.map(function(wpt) {return {location: wpt, stopover: false};});
  } else {
    ary = [];
  }

  var request = {
    origin: "Seattle, WA",
    destination: "Portland, OR",
    waypoints: ary,
    travelMode: google.maps.TravelMode[selectedMode],
    unitSystem: google.maps.UnitSystem["IMPERIAL"]
  };
  directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
    }
  });
}

function watch_waypoints() {
  clear_markers();
  var wpts = directionsDisplay.directions.routes[0].legs[0].via_waypoints;
  for(var i=0; i<wpts.length; i++) {
    var marker = new google.maps.Marker({
        map: map,
        //icon: "/images/blue_dot.png",
        position: new google.maps.LatLng(wpts[i].lat(), wpts[i].lng()),
        title: i.toString(),
        draggable :true
        });
    waypoint_markers.push(marker);
    var infowindow = new google.maps.InfoWindow({ 
    content: "<table>" +
    "<tr><td>Waypoint:</td> <td><input type='text' id='name' value=''/> </td> </tr>" +
    "<tr><td>Waypoint Description:</td> <td><input type='text' id='address' value=''/></td> </tr>" +
    "<tr><td><input type='hidden' value='"+marker.getPosition()+"'id='hiddenval'></td></tr>"+
    "<tr><td></td><td><input type='button' value='Save & Close' onclick='saveData(<?php print_r(node_load(arg(1))->nid);?>)'/></td></tr>"
});
    google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(map,marker);

    });
    google.maps.event.addListener(marker, 'dblclick', function() {
        marker.setMap(null);
        wpts.splice(parseInt(this.title), 1);
        calcRoute(wpts);
        directionsDisplay.setOptions({ preserveViewport: true, draggable: true});
    });
  }
}
function clear_markers() {
  for(var i=0; i<waypoint_markers.length; i++){
    waypoint_markers[i].setMap(null);
  }
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body onload="init()">
<div id="directionsPanel"></div>
<div id="map"></div>
</body>
</html>
于 2011-10-25T10:31:42.703 に答える
1

おそらく、Google マップを実行するための優れた php クラスであるGmapper ( http://sourceforge.net/projects/gmapper/ ) を試してみてください。すべての JavaScript を生成する簡単な方法であり、アドレスを検索することもできます。Google はアドレスの検索数を制限していることに注意してください。おそらく 1 日でデータベースを取得することはできません。

于 2009-11-03T21:28:26.290 に答える
1

私がほぼ正確に行ったサイトを教えてもらえますか (ただし、マーカーをクリックするのではなく、ホバーすると更新されます。ホバー イベントではなく、提供された空のクリック イベントにコードを移動するだけです)。本当のコーディングの精神で、うまくいけば、私が行ったことを適応させることができます!

http://www.primrose-house.co.uk/localattractions

于 2009-11-26T11:32:24.967 に答える