对于javascript–如何使谷歌地图默认指向美国?感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍谷歌地图调用,并为您提供关于javascript–与经过验证的位置进行交互?–谷歌地图、ja
对于javascript – 如何使谷歌地图默认指向美国?感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍谷歌地图调用,并为您提供关于javascript – 与经过验证的位置进行交互? – 谷歌地图、javascript – 使用谷歌地图API将视频附加到标记、javascript – 允许用户在谷歌地图上放置标记、javascript – 允许用户在谷歌地图自定义地图中移回标记位置(z-index?)的有用信息。
本文目录一览:- javascript – 如何使谷歌地图默认指向美国?(谷歌地图调用)
- javascript – 与经过验证的位置进行交互? – 谷歌地图
- javascript – 使用谷歌地图API将视频附加到标记
- javascript – 允许用户在谷歌地图上放置标记
- javascript – 允许用户在谷歌地图自定义地图中移回标记位置(z-index?)
javascript – 如何使谷歌地图默认指向美国?(谷歌地图调用)
我需要在选项{}中添加什么值?
var myOptions = { zoom: 4,??????,mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
解决方法
var latlng = new google.maps.LatLng(37.09024,-95.712891); var myOptions = { zoom: 3,center: latlng,mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions);
在Google地图上搜索某个地点后,您可以在大多数浏览器中添加
javascript:void(prompt('',gApplication.getMap().getCenter()));
在地址栏中获取纬度和经度坐标
或者您可以使用名为“USA”的反向地理编码,如下所示:
geocoder.geocode( {'address': 'USA' },function(results,status) { response($.map(results,function(item) { var latlng = new google.maps.LatLng( item.geometry.location.lat(),item.geometry.location.lng()); var myOptions = { zoom: 3,mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"),myOptions); })); });
javascript – 与经过验证的位置进行交互? – 谷歌地图
好的,所以这些天在Google地图上标记了很多商家.
但我不能以任何方式与这些互动.
这是我的信息:
venue name: Ministry of Sound
address: 103 Gaunt Street London,SE1 6DP
谷歌的地理位置只给了我
>坐标(纬度,长度)
>格式化地址
我想要一个应用程序来访问此页面 – > Ministry of Sound – Google Page
我想要:
>添加评论(例如Qype,ViewLondon,Frommers这样的网站!)
>添加照片和视频
>添加其他内容
我还想:
>如果可能,自动将地址链接到商家
eg. if the business shares the same address
编辑:
SilentGhost说“谷歌只是索引和汇总来自网站的信息”
如果在网站上获取评论和信息的唯一方法是将其编入索引…
如何告诉Google我的网站包含的内容:
>场地照片
>场地的评论
>有关场地的信息?
非常感谢帮助.谢谢!
总结
以上是小编为你收集整理的javascript – 与经过验证的位置进行交互? – 谷歌地图全部内容。
如果觉得小编网站内容还不错,欢迎将小编网站推荐给好友。
javascript – 使用谷歌地图API将视频附加到标记
已经取得的成果:基本的谷歌地图代码,用于在特定位置放置标记
想法:使用定义的标记变量来附加视频
尝试使用Infowindow,但它没有显示视频.请注意,视频与包含我的代码的文件位于同一文件夹中.有人可以帮忙吗?
<!DOCTYPE html> <html> <head> <script src="http://maps.googleapis.com/maps/api/js?&sensor=false"> </script> <script> function initialize() { var mapProp = { center:new google.maps.LatLng(-20.240154,57.589669),zoom:10,mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google.maps.Map(document.getElementById("googleMap"),mapProp); var curepipe=new google.maps.Marker({ position: new google.maps.LatLng(-20.318813,57.524149) }); curepipe.setMap(map); var infowindow = new google.maps.InfoWindow({ content:"Hello World!" }); infowindow.open(map,marker); } } google.maps.event.addDomListener(window,'load',initialize); </script> </head>
解决方法
Aaaand,只做了一些小改动:
function initialize() { var mapProp = { center: new google.maps.LatLng(-20.240154,zoom: 10,mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("googleMap"),mapProp); var curepipe = new google.maps.Marker({ position: new google.maps.LatLng(-20.318813,57.524149) }); curepipe.setMap(map); var infowindow = new google.maps.InfoWindow({ content: '<video controls=""poster="poster.png">' + '<source src="http://www.html5rocks.com/en/tutorials/video/basics/devstories.webm" type="video/webm;">' + '<source src="http://www.html5rocks.com/en/tutorials/video/basics/devstories.mp4" type="video/mp4;">' + '</video>' }); infowindow.open(map,curepipe); } google.maps.event.addDomListener(window,initialize);
<script src="https://maps.googleapis.com/maps/api/js?&sensor=false"></script> <div id="googleMap"></div>
编辑
我使用的视频来自this页
javascript – 允许用户在谷歌地图上放置标记
是否可以允许用户动态执行此操作?我已经看过here并且明白我可以使用经度和纬度来做到这一点.因此,使用上述方法可以从用户点击获得经度和纬度吗?
解决方法
javascript – 允许用户在谷歌地图自定义地图中移回标记位置(z-index?)
我想允许用户能够在InfoWindow内的点击上移动自定义谷歌地图标记的顺序.这是为了克服重叠标记的问题.我考虑过其他解决方案(移动lat / lon,标记簇,“蜘蛛标记”).
我的代码有两个问题:1)jquery监听器不工作2)但更重要的是如何实现z-index(或其他技术?)的更改和重新显示.
<!DOCTYPE html>
<html>
<head>
<style>
#map-canvas, #side-bar {
height: 500px;
width: 600px;
}
</style>
<script src="http://maps.googleapis.com/maps/api/js" type="text/javascript"></script>
<script src="../jquery/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
// scoping for jquery
$( document ).ready(function() {
"use strict";
// variable to hold a map
var map;
// variable to hold current active InfoWindow
var activeInfoWindow ;
// ------------------------------------------------------------------------------- //
// initialize function
// ------------------------------------------------------------------------------- //
function initialize() {
// ------------------------------------------------------------------------------- //
// LISTENER ON CLICK EVENT
// ------------------------------------------------------------------------------- //
$( "a" ).on( "click", function() {
alert("got here!");
// do something to change z-index of this marker
//...
// my_index = my_index-1;
//...
return false;
});
// map options - lots of options available here
var mapOptions = {
zoom : 5,
draggable: true,
center : new google.maps.LatLng(44.960, -93.100),
mapTypeId : google.maps.MapTypeId.ROADMAP
};
// create map in div called map-canvas using map options defined above
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
// define two Google Map LatLng objects representing geographic points
var stPaul = new google.maps.LatLng(44.95283,-93.08925);
var minneapolis = new google.maps.LatLng(44.97984,-93.26620);
// place two markers
fnPlaceMarkers(stPaul,"St Paul");
fnPlaceMarkers(minneapolis,"Minneapolis");
}
// ------------------------------------------------------------------------------- //
// create markers on the map
// ------------------------------------------------------------------------------- //
function fnPlaceMarkers(myLocation,myCityName){
var marker = new google.maps.Marker({
position : myLocation
});
// Renders the marker on the specified map
marker.setMap(map);
// create an InfoWindow
var infoWnd = new google.maps.InfoWindow();
// add content to your InfoWindow
infoWnd.setContent('<div>' + 'Welcome to ' + myCityName + '<br/><a href="#">Click</a> to move this marker to the back</div>');
// add listener on InfoWindow - close last infoWindow before opening new one
google.maps.event.addListener(marker, 'click', function() {
//Close active window if exists - [one might expect this to be default behavIoUr no?]
if(activeInfoWindow != null) activeInfoWindow.close();
// Open InfoWindow
infoWnd.open(map, marker);
// Store new open InfoWindow in global variable
activeInfoWindow = infoWnd;
});
}
// ------------------------------------------------------------------------------- //
// initial load
// ------------------------------------------------------------------------------- //
google.maps.event.addDomListener(window, 'load', initialize);
}); // end query
</script>
<div id="map-canvas"></div>
</body>
</html>
解决方法:
>为所有标记设置zIndex(否则未定义),好的值是(纬度* -100000)<< 5(来自古代史上的迈克威廉姆斯)
var marker = new google.maps.Marker({
position: myLocation,
zIndex: Math.round(myLocation.lat()*-100000)<<5
});
>保持对所有标记的引用(数组标记)
markers.push(marker);
>单击链接时,将zIndex减去-100000.
working fiddle
代码段:
function setMarkerBack(i) {
var currentZ = markers[i].get('zIndex');
markers[i].set('zIndex', currentZ - 100000);
}
var markers = [];
// scoping for jquery
$(document).ready(function() {
"use strict";
// variable to hold a map
var map;
// variable to hold current active InfoWindow
var activeInfoWindow;
// ------------------------------------------------------------------------------- //
// initialize function
// ------------------------------------------------------------------------------- //
function initialize() {
// ------------------------------------------------------------------------------- //
// LISTENER ON CLICK EVENT
// ------------------------------------------------------------------------------- //
$("a").on("click", function() {
alert("got here!");
// do something to change z-index of this marker
//...
// my_index = my_index-1;
//...
return false;
});
// map options - lots of options available here
var mapOptions = {
zoom: 5,
draggable: true,
center: new google.maps.LatLng(44.960, -93.100),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// create map in div called map-canvas using map options defined above
map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
// define two Google Map LatLng objects representing geographic points
var stPaul = new google.maps.LatLng(44.95283, -93.08925);
var minneapolis = new google.maps.LatLng(44.97984, -93.26620);
// place two markers
fnPlaceMarkers(stPaul, "St Paul");
fnPlaceMarkers(minneapolis, "Minneapolis");
}
// ------------------------------------------------------------------------------- //
// create markers on the map
// ------------------------------------------------------------------------------- //
function fnPlaceMarkers(myLocation, myCityName) {
var marker = new google.maps.Marker({
position: myLocation,
zIndex: Math.round(myLocation.lat() * -100000) << 5
});
// Renders the marker on the specified map
marker.setMap(map);
var i = markers.length;
markers.push(marker);
// create an InfoWindow
var infoWnd = new google.maps.InfoWindow();
// add content to your InfoWindow
infoWnd.setContent('<div>' + 'Welcome to ' + myCityName + '<br/><a href="javascript:setMarkerBack(' + i + ');">Click</a> to move this marker to the back<br>zIndex=' + marker.get('zIndex') + '</div>');
// add listener on InfoWindow - close last infoWindow before opening new one
google.maps.event.addListener(marker, 'click', function() {
//Close active window if exists - [one might expect this to be default behavIoUr no?]
if (activeInfoWindow != null) activeInfoWindow.close();
// Open InfoWindow
infoWnd.open(map, marker);
// Store new open InfoWindow in global variable
activeInfoWindow = infoWnd;
});
}
// ------------------------------------------------------------------------------- //
// initial load
// ------------------------------------------------------------------------------- //
google.maps.event.addDomListener(window, 'load', initialize);
}); // end query
html,
body,
#map-canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<div id="map-canvas"></div>
今天的关于javascript – 如何使谷歌地图默认指向美国?和谷歌地图调用的分享已经结束,谢谢您的关注,如果想了解更多关于javascript – 与经过验证的位置进行交互? – 谷歌地图、javascript – 使用谷歌地图API将视频附加到标记、javascript – 允许用户在谷歌地图上放置标记、javascript – 允许用户在谷歌地图自定义地图中移回标记位置(z-index?)的相关知识,请在本站进行查询。
本文标签: