私は Google マップ API Web アプリケーションの初心者開発者で、質問があります。どの方程式(Javascript)が長方形のポリゴン領域で私のマーカーポイントを見つけるか、これは例です:
これは私のスクリプトです:
$(document).ready(function(){
$('#map_canvas').height($('#content').height());
});
var map;
var tableID = 'myid';
var auth = true;
var cloudData;
var authLink;
var rectangleCloud = new Array();
function initialize(){
result = JSON.parse(token);
getFeature(result.access_token);
showMap(result.access_token);
}
function showMap(authResult) {
// Create a new Google Maps API Map
var mapOptions = {
center: new google.maps.LatLng(13.74657604702232,100.53490161895752),
zoom: 6,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
//console.log(getFeatureById(mapsEngineLayer.featureId));+
google.maps.event.addListener(mapsEngineLayer, 'bounds_changed', function() {
map.fitBounds(mapsEngineLayer.get('bounds'));
});
//i think add equation at this.
window.setTimeout(refreshToken, authResult.expires_in * 1000);
}
function getFeature(authResult){
// List the details of a specific Google Maps Engine Map.
var url = "https://www.googleapis.com/mapsengine/v1/tables/"+tableID+"/features";
jQuery.ajax({
url: url,
dataType: 'json',
headers: {
'Authorization': 'Bearer ' + authResult
},
success: function(response) {
// Log the details of the Map.
cloudData = response;
console.log(cloudData.features);
//this is a data callback from mapengine api
},
error: function(response) {
response = JSON.parse(response.responseText);
console.log("Error: ", response);
window.location(authLink);
}
});
}
function loadScript() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=visualization&language=th&callback=initialize';
document.body.appendChild(script);
}
function createButtonAuth(){
console.log("in");
var inDiv = document.getElementById('mapWindown');
var iDiv = document.createElement('div');
iDiv.id = 'buttonAuth';
iDiv.className = 'buttonAuth-style';
iDiv.innerHTML = "<button class='btn btn-large btn-block btn-primary' type='button'><a href='$authUrl'>Authorize this application</a></button>";
iDiv.appendChild(inDiv);
}
window.onload = loadScript;
回答ありがとうございます。