向GMaps添加标记(谷歌地图) [英] Adding a marker to GMaps (google maps)

查看:139
本文介绍了向GMaps添加标记(谷歌地图)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用此工具: http://software.stadtwerk.org/google_maps_colorizr/向我的谷歌地图添加颜色,这里是我的例子:

I'm trying to use this tool: http://software.stadtwerk.org/google_maps_colorizr/ to add colour to my google map, here is my example:

http://jsfiddle.net/xUUxn/851/

颜色可以正常工作,但现在我似乎无法添加任何标记它,我试着把这个例子代码:

The colour works fine, but now I can't seem to add any markers to it, I've tried putting this example code in:

map.addMarker({ 
  lat: -12.043333,
  lng: -77.028333,
  title: 'Lima',
  infoWindow: {
    content: '<p>HTML Content</p>'
  }
 });

但它似乎不起作用,我不完全确定它放在哪里或甚至如果引用是正确的。

But it doesn't seem to work, I'm not entirely sure where to put it or even if the references are correct.

推荐答案

为了创建标记,您需要执行以下操作:

In order to create a marker you need to do the following:

示例从您的示例中分出: http://jsfiddle.net/lucuma / xUUxn / 852 /

Demo forked from your example: http://jsfiddle.net/lucuma/xUUxn/852/

JS:

JS:

var marker = new google.maps.Marker({
        position: new google.maps.LatLng( -12.043333,-77.028333),
        map: map,
        title: 'Hello World!'
    });

添加信息窗口叠加层:

To add an info window overlay:

var contentString = '<div id="content"><h1>Overlay</h1></div>';
  var infowindow = new google.maps.InfoWindow({
            content: contentString
  });


google.maps.event.addListener(marker, 'click', function() {
          infowindow.open(map,marker);
        });

这篇关于向GMaps添加标记(谷歌地图)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆