开发者

Showing Google Place Page data in the infowindow through a Google Maps API V3 generated map

开发者 https://www.devze.com 2023-02-18 22:38 出处:网络
I\'ve got a map coming through just fine with a marker 开发者_JAVA百科where I\'d like, and am able to get the infowindow to show with custom content.

I've got a map coming through just fine with a marker 开发者_JAVA百科where I'd like, and am able to get the infowindow to show with custom content.

What I'd like instead though, is to have the defualt google place page info to show up in the info box as you'd find it on maps.google.com. Example here.

The only reason I'm using the Maps API instead of the embed is that we need to move the map controls out of the top left corner. If there is a way to embed a map and move the controls that would be great! Otherwise I need to be able to pull the Place content into the infowindow I'm generating. My code is below.

var latlng = new google.maps.LatLng(43.6985770, -73.7154730);
var mapOptions = {
        zoom: 17,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        mapTypeControl: false,
        zoomControl: true,
        zoomControlOptions: {
            style: google.maps.ZoomControlStyle.DEFAULT,
            position: google.maps.ControlPosition.RIGHT_TOP
        },
        streetViewControl: false,
        panControl: false,
        scaleControl: false
    };

var map = new google.maps.Map(document.getElementById("map_canvas"),
    mapOptions);

var contentString = '<h1>Title</h1> <p>Content</p>';

var infowindow = new google.maps.InfoWindow({
    content: contentString,
    maxWidth: 260
});

var marker = new google.maps.Marker({
    position: latlng,
    map: map,
    title:"Directions!"
});

infowindow.open(map,marker);

Thanks!


You should look at the Google Place API.

0

精彩评论

暂无评论...
验证码 换一张
取 消