以下は、3 つのマップを含むサンプル HTML です。開発者ツールで HTML を調べて、Sitefinity からの引数が期待どおりに返されていることを確認します。また、住所、都市、州の間にスペースまたはカンマがあることを確認してください。また、Sitefinity 6 を使用している場合は、Google マップが組み込まれています。
<html>
<head></head>
<body>
<iframe width='500' height='240' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=510 W Main St Fort Wayne IN&aq=0&oq=510 W Main St Fort Wayne IN&ie=UTF8&hq=&hnear=510 W Main St Fort Wayne IN&z=14&output=embed&iwloc=near'></iframe>
<iframe width='500' height='240' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=1770 Apple Glen Blvd Fort Wayne IN&aq=0&oq=1770 Apple Glen Blvd Fort Wayne IN&ie=UTF8&hq=&hnear=1770 Apple Glen Blvd Fort Wayne IN&z=14&output=embed&iwloc=near'></iframe>
<iframe width='500' height='240' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=1600 Amphitheatre Pkwy, Mountain View, CA&aq=0&oq=1600 Amphitheatre Pkwy, Mountain View, CA&ie=UTF8&hq=&hnear=1600 Amphitheatre Pkwy, Mountain View, CA&z=14&output=embed&iwloc=near'></iframe>
</body>
</html>
Google マップ V3 API を使用します。JavaScript を貼り付けて、sitefiniy のウィジェット内に div をマップし、<%#Eval("address")%> を GetLatLong() 関数に渡される文字列として使用します。
<html html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=YOURKEYHERE&sensor=false"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<script>
var geocoder = new google.maps.Geocoder();
var marker;
var map;
$(document).ready(function(){
initialize();
});
function initialize() {
var mapOptions = {
zoom: 10,
center: new google.maps.LatLng(39.8282, -98.5795),//US Center as Default
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
GetLatLong("201 W Main St Fort Wayne IN");//Use your <%#Eval("Address")%> here Like
//GetLatLong('<%#Eval("Street")%> <%#Eval("City")%> <%#Eval("State")%> ');
}
function GetLatLong(address){
if (geocoder)
{
geocoder.geocode({ 'address': address }, function (results,status) {
if (status == google.maps.GeocoderStatus.OK)
{
var l = results[0].geometry.location;
map.setCenter(l);
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: address
});
}
else
{
}
});
}
}
</script>
</head>
<body>
<div id="map-canvas" style="height:500px;width:500px;"></div>
</body>
</html>