java google地图插入标点_java – 如何在google地图上放置标记

Problem 1: Once the marker is placed, it cannot be placed again.

这个问题是由以下原因引起的:

>您已将纬度和经度绑定到不同的bean(NewOfferSupportController),而不是包含地图模型(MapBean)的bean。您应该在PrimeFaces展示区中使用MapBean示例作为NewOfferSupportController bean的设计起点。它存储标记集。隐藏输入必须指向该bean,因为在addMarker()方法中,将添加这些值。从展示示例中,您只需重命名MapBean类名称,然后通过#{newOfferSupportController}重命名视图中的#{mapBean}引用。

>您的NewOfferSupportController bean是请求作用域,而它应该是视图作用域。

@ManagedBean

@ViewScoped

public class NewOfferSupportController implements Serializable {}

只要你使用Ajax的相同形式进行交互,视图范围bean就可以生效。但是请求范围bean在每个请求(因此也在每个Ajax请求!)上被重新创建,从而破坏在地图中放置的标记和在添加标记之前输入的标记。

Problem 2: In the same form where the map is there are some other elements such as text fields. Actually the form does not get submitted at all(This didn’t occur before i added the map), why is the map disrupting the validation?

这对我有用。这可能是因为您的NewOfferSupportController已放置在请求范围而不是视图范围中。

总结一下,这里是我在我的测试中使用的代码:

视图:

model="#{mapBean.mapModel}" onPointClick="handlePointClick(event);" widgetVar="map" />

update="messages" oncomplete="markerAddComplete()"/>

(我没有更改的示例中的代码,只是添加不变)

豆:

@ManagedBean

@ViewScoped

public class MapBean implements Serializable {

private MapModel mapModel;

private String title;

private double lat;

private double lng;

private String input;

public MapBean() {

mapModel = new DefaultMapModel();

}

public void addMarker(ActionEvent actionEvent) {

mapModel.addOverlay(new Marker(new LatLng(lat, lng), title));

addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Marker Added", "Lat:" + lat + ", Lng:" + lng));

}

public void submit() {

addMessage(new FacesMessage(FacesMessage.SEVERITY_INFO, "Form submitted", "Amount markers: " + mapModel.getMarkers().size() + ", Input: " + input));

}

public void addMessage(FacesMessage message) {

FacesContext.getCurrentInstance().addMessage(null, message);

}

// Getters+setters.

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
任何 Google 地图 API 应用程序中的基础元素都是“地图”本身。 大量应用js,访问Google 的API。 在此之前较为麻烦的事申请Google 的key,相比都知道,Google 在中国市场的地位,因此Google 的key较难申请, .Google Maps API 申请方式变更在Google Maps API 的部份,官方网站目前是建议使用新版本(v3)的API 进行开发,若您仍希望继续使用v2 的版本进行开发,您可能需要进行部份设定的修改,底下是设定的流程:   1.使用Google帐号登入APIs Console (https://code.google.com/apis/console),并将Google Maps API v2的选项打开,如下图所示: Google Maps API v2设置   2.依据您的需求产生对应的Google Maps API Key ,若您是要继续采用v2 版本的方式使用Google Maps API ,请选择「Create new Browser Key」,之后将产生的Key 依据过去的方式填入对应的位置即可 注意V2版本对应的选项   需要注意的是:   1.依目前观察,已经在使用中的Google Maps API Key 是可以继续使用,并不会因为产生Key 的方式改变而有所变更。   2.新的方式会统计并限制使用量(目前是限制每天25,000 次查询),若超过用量则需给付相关费用才可继续使用。 最近发现好多google的域名不能访问了!包括Android开发SDK都不能更新了!解决方法: 修改hosts文件 添加: 74.125.71.99 code.google.com 74.125.71.99 encrypted.google.com 74.125.71.99 suggestqueries.google.com 74.125.71.99 mail.google.com 74.125.71.99 groups.google.com 74.125.71.99 groups.google.com.hk 74.125.71.99 docs.google.com 74.125.71.99 docs0.google.com 74.125.71.99 docs1.google.com 74.125.71.99 spreadsheets.google.com 74.125.71.99 spreadsheets0.google.com 74.125.71.99 webcache.googleusercontent.com 74.125.71.99 sites.google.com 74.125.71.99 talkgadget.google.com 74.125.71.99 clients1.google.com 74.125.71.99 clients2.google.com 74.125.71.99 clients3.google.com 74.125.71.99 clients4.google.com 整个开发有些事情较做只可意会,不可言传,当然纯属的代码并不是最大的效益,需要文档的可以找我,工程部署不了的可以联系我。 email:lcyangmi@163.com MSN:yummy@chinaclick.com.cn
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值